![]() |
Re: FTP URL in Bestandteile splitten
hallo,
wie ist denn das jetzt, wenn man als passwort eine email hat: ![]() bei den beispielen hier, TIdURI und internetcrackurl wird als passwort 'eine' und als host 'mail.de@server.com' zurückgegeben ... was nun? |
Re: FTP URL in Bestandteile splitten
Hi,
ich würde es mit dem für URL encodierten Code für das @-Zeichen probieren: %40, also sollte die URL dann so aussehen: "ftp://benutzer:e%40mail.de@server:port/verzeichnis/file.ext". Auf ![]() cu |
Re: FTP URL in Bestandteile splitten
Da musst du den ersten Klammeraffen wohl Url-encoden '@' => %40, also
![]() //EDIT: roten Kasten ignoriert |
Re: FTP URL in Bestandteile splitten
mein vorschlag: (funzt mit emails im user und pass)
Delphi-Quellcode:
GetFilename kopiert einfach nur den filename raus ...
type
TMyURL = record url, protocol, user, pass, host, port, path, filename : String; end; function CrackUrl(url : String; var res : TMyURL):boolean; var atpos, tmppos : integer; hp, rest : string; begin try tmppos := 0; res.url := url; res.protocol := copy(url,0,pos('://',url)-1); url := copy(url,pos('://',url)+3,length(url)); res.user := copy(url,0,pos(':',url)-1); url := copy(url,pos(':',url)+1,length(url)); repeat atpos := tmppos; tmppos := PosEx('@',url,tmppos+1); until tmppos+atpos = atpos; res.pass := copy(url,0,atpos-1); url := copy(url,atpos+1,length(url)); hp := copy(url,0,pos('/',url)-1); if pos(':',hp)=0 then begin res.host := hp; res.port := '21'; end else begin res.host := copy(hp,0,pos(':',hp)-1); res.port := copy(hp,pos(':',hp)+1,length(hp)); end; url := copy(url,pos('/',url),length(url)); res.filename := fMain.GetFileName(url); if (res.filename = '') or (pos('.',res.filename)=0) then res.path := copy(url,0,length(url)) else res.path := copy(url,0,pos(res.filename,url)-1); Result := true; except Result := false; end; end; das ganze könte man jez noch mehr absichern, indem man auch des letzte ':' und auch auf unglückliche '/' im user/pass prüft ... mfg, eyeless |
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:00 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz