brendanhay / amazonka

A comprehensive Amazon Web Services SDK for Haskell.
https://amazonka.brendanhay.nz
Other
599 stars 227 forks source link

`amazonka-core`: urldecode parts when parsing to `QueryString` #780

Closed endgame closed 2 years ago

endgame commented 2 years ago

The query string parser did not handle %-encoding:

Before:

> parseQueryString "PostedBefore=2022-05-31T23%3A16%3A43Z&MaxResultsPerPage=100&PostedAfter=2022-05-31T22%3A16%3A43Z"
QList [QPair "PostedBefore" (QValue (Just "2022-05-31T23%3A16%3A43Z")),QPair "MaxResultsPerPage" (QValue (Just "100")),QPair "PostedAfter" (QValue (Just "2022-05-31T22%3A16%3A43Z"))]

After:

> parseQueryString "PostedBefore=2022-05-31T23%3A16%3A43Z&MaxResultsPerPage=100&PostedAfter=2022-05-31T22%3A16%3A43Z"
QList [QPair "PostedBefore" (QValue (Just "2022-05-31T23:16:43Z")),QPair "MaxResultsPerPage" (QValue (Just "100")),QPair "PostedAfter" (QValue (Just "2022-05-31T22:16:43Z"))]
endgame commented 2 years ago

I thought about replacing QueryString with Network.HTTP.Types.URI.Query, but that would involve rewriting a lot of old and battle-tested signing code, and I felt that the risk of breaking Amazonka for literally everyone was unacceptable.

I am currently checking every time we parse query strings in generated code, by temporarily removing the instance IsString QueryString and combing through the compilation failures.