From c36919073910a98ddf1b8008227e0f5ede1a53bb Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sat, 3 Oct 2009 20:08:12 +0200 Subject: Parse out password from URI entered in the Quick Connect dialog and reuse it on first password prompt --- UCoreUtils.pas | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'UCoreUtils.pas') 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 -- cgit v1.2.3