diff --git a/packages/fcl-base/src/uriparser.pp b/packages/fcl-base/src/uriparser.pp
index 10ffc90ad8..58d07e28df 100644
--- a/packages/fcl-base/src/uriparser.pp
+++ b/packages/fcl-base/src/uriparser.pp
@@ -207,7 +207,7 @@ function ParseURI(const URI, DefaultProtocol: String; DefaultPort: Word;Decode :
Result.Bookmark := Copy(s, i + 1, MaxInt);
if Decode then
Result.Bookmark:=Unescape(Result.Bookmark);
- s := Copy(s, 1, i - 1);
+ SetLength(s, i - 1);
end;
// Extract the params
@@ -218,7 +218,7 @@ function ParseURI(const URI, DefaultProtocol: String; DefaultPort: Word;Decode :
Result.Params := Copy(s, i + 1, MaxInt);
if Decode then
Result.Params:=Unescape(Result.Params);
- s := Copy(s, 1, i - 1);
+ SetLength(s, i - 1);
end;
// extract authority
@@ -248,7 +248,7 @@ function ParseURI(const URI, DefaultProtocol: String; DefaultPort: Word;Decode :
if Decode then
Result.Document:=Unescape(Result.Document);
if (Result.Document <> '.') and (Result.Document <> '..') then
- s := Copy(s, 1, i)
+ SetLength(s, i)
else
Result.Document := '';
break;
@@ -287,7 +287,7 @@ function ParseURI(const URI, DefaultProtocol: String; DefaultPort: Word;Decode :
if PortValid then
begin
Result.Port := StrToInt(Copy(Authority, i + 1, MaxInt));
- Authority := Copy(Authority, 1, i - 1);
+ SetLength(Authority, i - 1);
end;
end;
@@ -296,11 +296,11 @@ function ParseURI(const URI, DefaultProtocol: String; DefaultPort: Word;Decode :
i := Pos('@', Authority);
if i > 0 then
begin
- Result.Host := Copy(Authority, i+1, MaxInt);
- Delete(Authority, i, MaxInt);
+ Result.Host := Copy(Authority, i + 1, MaxInt);
+ SetLength(Authority, i - 1);
// Extract username and password
- if Length(Authority) > 0 then
+ if Authority <> '' then
begin
i := Pos(':', Authority);
if i = 0 then