diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-10-03 20:08:12 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-10-03 20:08:12 +0200 |
| commit | c36919073910a98ddf1b8008227e0f5ede1a53bb (patch) | |
| tree | f3972bc56a710c9bf02dbe3a89b776a6a37bed51 /UCoreUtils.pas | |
| parent | 8fb18e8b91f9d0fe4c7d7df34989554c905fcfa8 (diff) | |
| download | tuxcmd-c36919073910a98ddf1b8008227e0f5ede1a53bb.tar.xz | |
Parse out password from URI entered in the Quick Connect dialog and reuse it on first password prompt
Diffstat (limited to 'UCoreUtils.pas')
| -rw-r--r-- | UCoreUtils.pas | 24 |
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 |
