瀏覽代碼

* Fixed hostname parsing when the protocol and the leading "//" are missing

sg 22 年之前
父節點
當前提交
5bd25ccc15
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      packages/base/netdb/uriparser.pp

+ 6 - 2
packages/base/netdb/uriparser.pp

@@ -2,8 +2,9 @@
     $Id$
     $Id$
     This file is part of the Free Pascal run time library.
     This file is part of the Free Pascal run time library.
     Copyright (c) 2003 by the Free Pascal development team
     Copyright (c) 2003 by the Free Pascal development team
+    Original author: Sebastian Guenther
 
 
-    Unit to parse complete URI in its parts.
+    Unit to parse complete URI in its parts or to reassemble an URI
     
     
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.
@@ -219,8 +220,11 @@ begin
 
 
   // Extract the hostname
   // Extract the hostname
 
 
-  if (Length(s) > 2) and (s[1] = '/') and (s[2] = '/') then
+  if ((Length(s) > 2) and (s[1] = '/') and (s[2] = '/')) or
+    ((Length(s) > 1) and (s[1] <> '/')) then
   begin
   begin
+    if s[1] <> '/' then
+      s := '//' + s;
     for i := Length(s) downto 1 do
     for i := Length(s) downto 1 do
       if s[i] in ['@', '/'] then
       if s[i] in ['@', '/'] then
       begin
       begin