Repository navigation
URL parameters from string URLs get doubly URL encoded #2865
Replies: 1 comment
|
I checked the exact URL in your question on HTTPX 0.28.1. Passing it directly as the request URL preserves the existing escapes: import httpx
url = "http://host/path?sub_url=https://other?a%3Db%26c%3Dd"
request = httpx.Request("GET", url)
assert str(request.url) == url
assert request.url.params["sub_url"] == "https://other?a=b&c=d"This only constructs a request; no network call is involved. The URL tests also cover preservation of existing percent encoding. There are two different input contracts: a complete, already-encoded URL can be supplied as above; values supplied through request = httpx.Request(
"GET", "http://host/path",
params={"sub_url": "https://other?a=b&c=d"},
)
assert request.url.params["sub_url"] == "https://other?a=b&c=d"Passing an already-quoted value inside that dictionary introduces another encoding layer: |
Uh oh!
There was an error while loading. Please reload this page.
Currently, I have an issue that prevents usage of the last version of httpx:
strobject, that I wish to process;strpossible, the query parameters from the URL need to be encoded. However, as slashes are not requiredhave naturally been re-encoded, in which slashes have not been encoded (http://host/path?sub_url=https://other?a%3Db%26c%3Dd);httpxdouble encodes the already existing%characters, sending thehttp://host/path?sub_url=https:%2F%2Fother?a%253Db%2526c%253Dd- and the server finds itself processing doubly-encoded URL parameters.I am not really bothered by the fact that slashes get URL-encoded (unlike #2864)
However, I guess my issue is the same as #2863 - I do not think that the
%character in my context should be URL encoded.All reactions