You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that the url parser is corrupting query params by incorrectly percent encoding them.
I noticed there's this comment which indicates this percent encoding does not accurately follow the spec.
For example if I have a URL with the following query parameter type=application/pdf it gets incorrectly encoded to type=application%2Fpdf which causes the server to throw an error.
This behavior does not match requests which doesn't corrupt the query params.
I've found similar behaviour as well which may or may not be intended.
This URL (as a string) http://localhost:8000/api.php?gcmtitle=Category:Yu-Gi-Oh!_Master_Duel_Forbidden_%26_Limited_Lists passed to the client is not transformed.
This URL http://localhost:8000/api.php?gcmtitle=Category:Yu-Gi-Oh!_Master_Duel_Forbidden_%26_Limited_Lists&prop=revisions|categories gets a pass through the encoder because | is unencoded, so the client ends up making the request GET /api.php?gcmtitle=Category:Yu-Gi-Oh!_Master_Duel_Forbidden_%2526_Limited_Lists&prop=revisions%7Ccategories, double-encoding & that was already encoded as %26 in the provided string.
http://localhost:8000/api.php?gcmtitle=Category:Yu-Gi-Oh!_Master_Duel_Forbidden_%26_Limited_Lists&prop=revisions%7Ccategories is once again unaffected, making the request GET /api.php?gcmtitle=Category:Yu-Gi-Oh!_Master_Duel_Forbidden_%26_Limited_Lists&prop=revisions%7Ccategories.
What's the status? This is causing big problems for me. I need to have a temporary workaround. Is there a downgrade path? or workaround like marking a url as "raw" if you're sure it does not need further escaping? I'm on 0.25.1 and suffer from this badly when generating Dall-E images with OpenAI, these look like this:
Then it goes through httpx, I'm not sure what it makes of it, but it's definitely returning 403. Is it being double encoded because there is a slash in image/png after the query string started?
Activity
kevinlul commentedon Oct 21, 2023
I've found similar behaviour as well which may or may not be intended.
This URL (as a string)
http://localhost:8000/api.php?gcmtitle=Category:Yu-Gi-Oh!_Master_Duel_Forbidden_%26_Limited_Listspassed to the client is not transformed.This URL
http://localhost:8000/api.php?gcmtitle=Category:Yu-Gi-Oh!_Master_Duel_Forbidden_%26_Limited_Lists&prop=revisions|categoriesgets a pass through the encoder because|is unencoded, so the client ends up making the requestGET /api.php?gcmtitle=Category:Yu-Gi-Oh!_Master_Duel_Forbidden_%2526_Limited_Lists&prop=revisions%7Ccategories, double-encoding&that was already encoded as%26in the provided string.http://localhost:8000/api.php?gcmtitle=Category:Yu-Gi-Oh!_Master_Duel_Forbidden_%26_Limited_Lists&prop=revisions%7Ccategoriesis once again unaffected, making the requestGET /api.php?gcmtitle=Category:Yu-Gi-Oh!_Master_Duel_Forbidden_%26_Limited_Lists&prop=revisions%7Ccategories.lloydzhou commentedon Nov 8, 2023
#2844 (reply in thread)
dhensen commentedon Nov 9, 2023
What's the status? This is causing big problems for me. I need to have a temporary workaround. Is there a downgrade path? or workaround like marking a url as "raw" if you're sure it does not need further escaping? I'm on 0.25.1 and suffer from this badly when generating Dall-E images with OpenAI, these look like this:
https://oaidalleapiprodscus.blob.core.windows.net/private/org-xyxgxKHDKa9h2SyZk74VacjY/user-6CZ2Z6xmqMCEoabzlurm1utH/img-Lpem8k7ZbBvQ3A8zD8jlnPtb.png?st=2023-11-09T22%3A41%3A21Z&se=2023-11-10T00%3A41%3A21Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-11-09T19%3A51%3A33Z&ske=2023-11-10T19%3A51%3A33Z&sks=b&skv=2021-08-06&sig=OlpIVcF7OR%2Bd56ERijj6wSynejpy0O33vdF17ZM167I%3D
Then it goes through httpx, I'm not sure what it makes of it, but it's definitely returning 403. Is it being double encoded because there is a slash in image/png after the query string started?
lloydzhou commentedon Nov 10, 2023
@dhensen
i got same error when download Dall-E images.
i create pr(#2929) to fix it.
elupus commentedon Dec 4, 2023
Encoding slash is not really a bug. But double encoding stuff already encoded is. It must decode before encoding in that case.
elupus commentedon Dec 4, 2023
@ttys0dev what server is this? It should url decode query parameters before checking them.
ttys0dev commentedon Dec 4, 2023
I think apache or something, not something I control.
Well...it doesn't....so we need a way to not url encode.
elupus commentedon Dec 4, 2023
Well apache will just forward it to the web application. So not the http server that decode. That said i also think we can revert parts of that change
ttys0dev commentedon Dec 4, 2023
I think it's some ancient perl based web application.
Shulyaka commentedon Dec 4, 2023
According to curl, it's
Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0Here is an example of a double encoded URL returned by dall-e:
The correct URL works:
And the second one doesn't: