Parse ftp url in which username / password / path has special characters like @, /

Usually ftp url format ftp://user[:pass]@ip[:port]/path

But now I got this line:

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

This seems to be ambiguous, because the result of the parsing could be:

  • password=1.1.1.1, path=@1.1.1.1/fml
  • password=1.1.1.1@1.1.1.1/, path=fml

Should I just tell the client that this is illegal, or is there a more convenient way to handle this? Thank..

+3
source share
1 answer

Special characters in usernames and passwords

If your remote server requires authentication, you can specify a username and password in the input line. Usernames and passwords must have the following special characters encoded in percent:

] [? / <~ # `! @ $% ^ and * () + =} |: "; ',> {space

Examples:

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
+4

All Articles