wol*_*f5x 5 ftp url parsing special-characters
一般情况下,ftp url 格式为ftp://user[:pass]@ip[:port]/path
但现在我得到了这个字符串:
ftp://dude:1.1.1.1@1.1.1.1/@1.1.1.1/fml
Run Code Online (Sandbox Code Playgroud)
看起来它是不明确的,因为解析结果可能是:
password=1.1.1.1, path=@1.1.1.1/fmlpassword=1.1.1.1@1.1.1.1/, path=fml我是否应该告诉客户这是非法的,还是有其他更友好的方式来处理它?谢谢..
用户名和密码中的特殊字符
如果您的远程服务器需要身份验证,您可以在输入 url 字符串中包含用户名和密码。用户名和密码应具有以下百分比编码的特殊字符:
] [?/<~#`! @ $ % ^ & * ( ) + = } | : " ;' , > { 空格
例子:
http://example.com/path/to/input.avi
https://example.com/path/to/input.mov
ftp://example.com/path/to/input.mp3
sftp://example.com/path/to/input.3gp
https://s3.amazonaws.com/bucket-name/input.mpeg
s3://bucket-name/input.mpeg (shorthand for the full HTTP S3 url)
Examples (with username "user" and password "pass!word"):
http://user:pass%21word@example.com/path/to/input.avi
https://user:pass%21word@example.com/path/to/input.mov
ftp://user:pass%21word@example.com/path/to/input.mp3
sftp://user:pass%21word@example.com/path/to/input.3gp
ftp://user:pass%21word@example.com/path/to/input.mp3
Some servers require the username include your domain name (username "user@example.com" and password "pass!word"):
http://user%40example.com:pass%21word@example.com/path/to/input.avi
https://user%40example.com:pass%21word@example.com/path/to/input.mov
ftp://user%40example.com:pass%21word@example.com/path/to/input.mp3
sftp://user%40example.com:pass%21word@example.com/path/to/input.3gp
ftp://user%40example.com:pass%21word@example.com/path/to/input.mp3
Run Code Online (Sandbox Code Playgroud)