38

I am trying to setup an HTTP proxy on a Windows machine. Problem is, the password has a special character (@) in it that is causing the set command to fail.

I have tried both escaping the character (\@) and percent-encoding it with the hex value (%40), to no avail.

For example, with the username Foo and password B@r, I have tried the following commands:

set http_proxy=http://foo:B\@r@http-gateway.domain.org:80
set http_proxy=http://foo:B%40r@http-gateway.domain.org:80

Other than changing the password how can I have the proxy use the password?

Indrek
  • 24,204
  • 14
  • 90
  • 93
pyropenguin
  • 381
  • 1
  • 3
  • 4
  • Is the set failing or is the tool using the http_proxy environment variable failing due to the @ symbol? – Mike Cornell Apr 22 '11 at 13:16
  • Yes. Because the format is username:password@server:port, having @ in the middle of your password causes the right hand side of your password to be considered the hostname, thus the hostname resolution above fails because it thinks the hostname is r@http-gateway.domain.org. The "r@" should not be there. – Philluminati Nov 03 '11 at 16:23
  • 3
    I tried using %40 and it worked (on Windows), are you sure? – thegreendroid Oct 29 '12 at 02:32
  • In fact, it works on both Windows and Linux (Ubuntu). – thegreendroid Oct 29 '12 at 02:55
  • duplicate http://stackoverflow.com/questions/6172719/escape-character-in-git-proxy-password – rofrol Aug 03 '15 at 11:41

4 Answers4

49

You have to percent-encode | encode the special characters. E.g. instead of this:

http://foo:B@r@http-gateway.domain.org:80

you write this:

http://foo:B%40r@http-gateway.domain.org:80

So @ gets replaced with %40.

Note: foo = username, b@r = password, http-gateway.domain.org = host proxy to connect

Ravi Parekh
  • 597
  • 4
  • 7
3

For any special characters, in username or password, we can always use UTF-8 encoded strings in its place. For example: ! can be replaced with %21

so the command would be, if password is abc!:

npm config set proxy http://user:abc%21@proxy.world.com:8080/

npm config set https-proxy http://user:abc%21@proxy.world.com:8080/

2

Use %Ascii code of the special character in hexadecimal notation for any special character. Suppose My password is AB@12#& then the password should be set as

git config --global http.proxy *http://usernamne:**AB%4012%23%26**@myipadress:portnumber*

Refer to ascii table for knowing the hexadecimal ascii code of any number.

Prasanna
  • 4,036
  • 5
  • 34
  • 51
-1

Based upon this answer on SO, can you try using ^ to escape the @ symbol?

Mike Cornell
  • 143
  • 1
  • 5
  • In response to both, the set is successful, it is the tool using the environment variable: `set http_proxy=http://foo:B^@r@http-gateway.domain.org:80` `jruby -S gem install rake` ERROR: While executing gem ... (URI::InvalidURIError) the scheme http does not accept registry part: foo:B@r@http-gateway.domain.org:80 (or bad hostname?) – pyropenguin Apr 22 '11 at 15:05
  • This is a Linux based question, not a Windows based question, using ^ doesn't work for me. I still get `wget: unable to resolve host address `tf4ce@server.company.com'` after setting the proxy environmental variable. – Philluminati Nov 03 '11 at 16:19
  • 2
    Actually it IS a Windows based question...I know pyropenguin personally. – Mike Cornell Nov 07 '11 at 18:24