PIP as an escape character # in a password?

I want to continue the question How to make pip work behind a proxy server

I have Windows Server and Python 3.5 (64).

In the password, my user includes #.

I am trying to use some solutions:

"C: \ Program Files \ Python35 \ scripts \ pip.exe" install --proxy http: // proxy_user: pwd # 123@proxy.su : 1111 TwitterApi

"C: \ Program Files \ Python35 \ scripts \ pip.exe" install --proxy "http: // proxy_user: pwd # 123" @ proxy.su: 1111 TwitterApi

"C: \ Program Files \ Python35 \ scripts \ pip.exe" install --proxy http: // "proxy_user: pwd # 123" @ proxy.su: 1111 TwitterApi

"C: \ Program Files \ Python35 \ scripts \ pip.exe" install --proxy http: // proxy_user: "pwd # 123" @ proxy.su: 1111 TwitterApi

BUT for error

  File "c: \ program files \ python35 \ lib \ site-packages \ pip \ _vendor \ requests \ package
s \ urllib3 \ util \ url.py ", line 189, in parse_url
    raise LocationParseError (url)
pip._vendor.requests.packages.urllib3.exceptions.LocationParseError: Failed to p
arse: proxy_user: pwd

How is the # escape character in this case?

+4
source share
2 answers

Quick exit . Enter it in an encoded form, i.e.# -> %23

OR

The best way to handle this element might be to add a --proxy-authflag that accepts: and does the encoding for before adding it to the proxy url.


Problem . This is not allowed:

, # userinfo URI, RFC 3986, . , : . , , , : urlencode , URI.

parse_url URL '/', '#' '?':

RFC :

( "//" ) ( "/" ), ( "?" ) ( "#" ) URI. , , / (? #), //. , -URI ? . , -, RFC .


+3
else examples
    $user = str_replace('@', '%40', $user);
    $pass = str_replace('%', '%25', $pass); // don't down! (%)
    $pass = str_replace('#', '%23', $pass);
    $pass = str_replace('@', '%40', $pass);
    $pass = str_replace(':', '%3a', $pass);
    $pass = str_replace(';', '%3b', $pass);
    $pass = str_replace('?', '%3f', $pass);
    $pass = str_replace('$', '%24', $pass);
    $pass = str_replace('!', '%21', $pass);
    $pass = str_replace('/', '%2f', $pass);
    $pass = str_replace('\'', '%27', $pass);
    $pass = str_replace('"', '%22', $pass);

0

Source: https://habr.com/ru/post/1652861/


All Articles