-1

I am writing a method to establish a connection to FTP and while configuring the URL, my password contains '@' character, which is in conflict with the host name. How can this be resolved? Can this character be escaped?

URL: ftp://xyz:abc@27@www.sezin.com/home/pk09
  • 2
    Auth information in the URL was deprecated ***years*** ago and implementors in various realms (browsers, for instance) are actively removing it, as it's ridiculously insecure. Surely there's a way to connect to your FTP server and *then* supply the auth info (which is still ridiculously insecure -- this is FTP -- but may at least be supported). – T.J. Crowder Nov 08 '17 at 18:19
  • Can you suggest the newer way to connect? – Prasanna Kumar S R Nov 08 '17 at 18:21
  • 2
    Are you using any library to connect to FTP?Surely there's a way to pass the credentials once the connection has been made. Refer http://www.beingjavaguys.com/2013/12/create-connection-to-ftp-in-java.html – inquizitive Nov 08 '17 at 18:23

1 Answers1

1

Strongly urge you not to do this. Quoting my comment (in case it gets cleaned up):

Auth information in the URL was deprecated years ago and implementors in various realms (browsers, for instance) are actively removing it, as it's ridiculously insecure. Surely there's a way to connect to your FTP server and then supply the auth info (which is still ridiculously insecure -- this is FTP -- but may at least be supported).

But the user information in the authority section of a URL (which is deprecated) are percent-encoded, so:

ftp://xyz:abc%4027@www.sezin.com/home/pk09

%40 is the percent-encoding value for @.

Community
  • 1
  • 1
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875