5

一般ftp url格式为ftp://user[:pass]@ip[:port]/path

但现在我得到了这个字符串:

ftp://dude:1.1.1.1@1.1.1.1/@1.1.1.1/fml

这似乎是模棱两可的,因为解析结果可以是:

  1. password=1.1.1.1, path=@1.1.1.1/fml
  2. password=1.1.1.1@1.1.1.1/, path=fml

我应该只告诉客户这是非法的,还是有更友好的方式来处理它?谢谢..

4

1 回答 1

5

用户名和密码中的特殊字符

如果您的远程服务器需要身份验证,您可以在输入 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
于 2014-07-16T13:50:56.813 回答