Browse Source

--- Merging r24280 into '.':
U packages/fcl-base/src/uriparser.pp

# revisions: 24280
r24280 | sergei | 2013-04-21 10:12:49 +0200 (Sun, 21 Apr 2013) | 2 lines
Changed paths:
M /trunk/packages/fcl-base/src/uriparser.pp

+ UriParser.pp: Consider 'port' part present in authority only if colon is followed by all digits. Mantis #24302.

git-svn-id: branches/fixes_2_6@24948 -

marco 12 years ago
parent
commit
51cfeb903d
1 changed files with 14 additions and 3 deletions
  1. 14 3
      packages/fcl-base/src/uriparser.pp

+ 14 - 3
packages/fcl-base/src/uriparser.pp

@@ -169,7 +169,8 @@ end;
 function ParseURI(const URI, DefaultProtocol: String; DefaultPort: Word;Decode : Boolean = True):  TURI;
 var
   s, Authority: String;
-  i: Integer;
+  i,j: Integer;
+  PortValid: Boolean;
 begin
   Result.Protocol := LowerCase(DefaultProtocol);
   Result.Port := DefaultPort;
@@ -267,8 +268,18 @@ begin
   i := LastDelimiter(':@', Authority);
   if (i > 0) and (Authority[i] = ':') then
   begin
-    Result.Port := StrToInt(Copy(Authority, i + 1, MaxInt));
-    Authority := Copy(Authority, 1, i - 1);
+    PortValid := true;
+    for j:=i+1 to Length(Authority) do
+      if not (Authority[j] in ['0'..'9']) then
+      begin
+        PortValid := false;
+        break;
+      end;
+    if PortValid then
+    begin
+      Result.Port := StrToInt(Copy(Authority, i + 1, MaxInt));
+      Authority := Copy(Authority, 1, i - 1);
+    end;
   end;
 
   // Extract the hostname