summaryrefslogtreecommitdiff
path: root/UCoreUtils.pas
diff options
context:
space:
mode:
Diffstat (limited to 'UCoreUtils.pas')
-rw-r--r--UCoreUtils.pas24
1 files changed, 24 insertions, 0 deletions
diff --git a/UCoreUtils.pas b/UCoreUtils.pas
index d82f657..f3617f6 100644
--- a/UCoreUtils.pas
+++ b/UCoreUtils.pas
@@ -99,6 +99,7 @@ function ConstructURI(IncludePasswd, HidePasswd: boolean; Protocol, Server, User
function URIHidePassword(const SrcURI: string): string;
function UnEscapeURI(const Str: string): string;
function EscapeURI(const Str: string; const IllegalChars: string): string;
+function URIRipPassword(var URI: string; const RemovePassword: boolean): string;
function StrTotimetDef(const S: string; const Default: time_t): time_t;
@@ -1091,6 +1092,29 @@ begin
end;
end;
+function URIRipPassword(var URI: string; const RemovePassword: boolean): string;
+var p: integer;
+ s: string;
+ SchemeStart, LoginEnd, PasswordStart: integer;
+begin
+ Result := '';
+ SchemeStart := Pos('://', URI);
+ if SchemeStart < 1 then Exit;
+ s := Copy(URI, SchemeStart + 3, Length(URI) - SchemeStart - 3);
+ p := Pos('/', s);
+ if p < 1 then p := Length(s);
+ Delete(s, p, Length(s) - p + 1);
+ p := PosEnd('@', s);
+ if p < 1 then Exit;
+ LoginEnd := p + SchemeStart + 2;
+ Delete(s, p, Length(s) - p + 1);
+ p := Pos(':', s);
+ if p < 1 then Exit;
+ PasswordStart := p + SchemeStart + 2;
+ Result := Copy(URI, PasswordStart + 1, LoginEnd - PasswordStart - 1);
+ if RemovePassword then Delete(URI, PasswordStart, LoginEnd - PasswordStart);
+end;
+
(********************************************************************************************************************************)
procedure DebugMsg(Params: array of const);
var