PIP如何在密码中转义字符#? [英] PIP how escape character # in password?

查看:316
本文介绍了PIP如何在密码中转义字符#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想继续提问 如何让pip在后台工作代理服务器

我有Windows Server和Python 3.5(64).

在密码中,我的用户包括#.

我尝试使用一些解决方法:

"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

但是会出错

  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

在这种情况下如何转义字符#?

解决方案

快速出路:以编码形式输入,即# -> %23

pip处理此问题的更好方法可能是添加--proxy-auth 带有的标志,并为 用户,然后将其添加到代理URL.


问题-不允许这样做:

严格来说,文字#字符在 URI的userinfo部分(根据RFC 3986),应为 百分比编码.但是,很多工具并不奇怪 好吧:显然没有任何实际的歧义 特点.但是请注意,如果 密码,您绝对必须使用urlencode密码:出于这个原因, 养成在输入密码之前对您的密码进行urlencode的好习惯 进入URI.

对提交的问题的响应 parse_url在URL中带有"/","#"或?" :

RFC专门说了:

授权组件前面带有双斜杠("//"),并且 由下一个斜杠("/"),问号(?")或数字终止 符号("#")字符或URI的末尾.换句话说, 当前的行为在期望授权是正确的 由前面的第一个/(或?或#)终止 //.我是否对尝试通过pip使用代理URI的人表示同情? 绝对地.我认为一起入侵违反RFC的内容 稍后可能会带来令人讨厌的惊喜.


want to continue question How to get pip to work behind a proxy server

I have Windows Server and Python 3.5 (64).

In password my user include #.

I try to use some solve:

"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 to get 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 escape character # in this case?

解决方案

Quick way out: Enter it in the encoded form i.e. # -> %23

OR

A better way for pip to handle this might be to add a --proxy-auth flag that takes : and does the encoding for the user before adding it to the Proxy URL.


Issue - This is something not allowed:

Strictly speaking, the literal # character is not valid in the userinfo portion of a URI, according to RFC 3986, and should be percent encoded. However, it's not exactly a surprise that many tools handle this ok: there's clearly no actual ambiguity about that character. Note, however, that if there were an @ symbol in the password you'd definitely have to urlencode it: for that reason, it's a good habit to get into to urlencode your passwords before they go into URIs.

The response to a submitted issue parse_url fails when given credentials in the URL with '/', '#', or '?':

The RFC says specifically:

The authority component is preceded by a double slash ("//") and is terminated by the next slash ("/"), question mark ("?"), or number sign ("#") character, or by the end of the URI. In other words, the current behaviour is correct in expecting the authority to be terminated by the first / (or ? or #) it finds after the preceeding //. Am I sympathetic to people trying to use proxy URIs with pip? Absolutely. I think hacking together something that violates the RFC has the potential for nasty surprises later on.


这篇关于PIP如何在密码中转义字符#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆