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

git-svn-id: trunk@24280 -
This commit is contained in:
sergei 2013-04-21 08:12:49 +00:00
parent 3e2cedaf59
commit 20ed97a1e2

View File

@ -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