httpx.URL() does not parse url correctly with curly brackets in password. #2350
Unanswered
xlash
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was having an error when trying to use httpx with a proxy configuration. After digging, I notice that the proxy url parsing is broken when certain characters are in the password, like a opening curly bracket in this example #2.
Known characters posing issues : [,],{,},@,/
The @ sign seems pretty obvious, but not necessarily the other ones. I can't find the specific RFC preventing the use of brackets.
httpx 0.23.0
To reproduce :
Outputs :
# Test case #1
URL('https://jo%40email.com:[secure]@xn--mller-kva.de:1234/pa%20th?search=ab#anchorlink')
# Test case #2
URL('HTTPS:/pa%20th?search=ab#anchorlink')
# Test case #3
URL('HTTPS:')
Expected output :
Probably raise a parsing issue ? Like if FQDN is invalid like in the Test case #2, or if it's empty like #3
Possible solution:
Encode all special characters in url with % sign before calling URL()
HTTPTransport() line 142
Workaround
You can use url encoding for username and password
username = urllib.parse.quote(username, safe='')
password = urllib.parse.quote(password, safe='')
Or build the proxy variable like this
httpx.Proxy(httpx.URL('HTTPS://müller.de:1234/pa%20th?search=ab#anchorlink', username='jo%40email.com', password='sec{ret')))
Beta Was this translation helpful? Give feedback.
All reactions