scotty-web / scotty

Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp (Official Repository)
http://hackage.haskell.org/package/scotty
BSD 3-Clause "New" or "Revised" License
1.71k stars 132 forks source link

URL-decode all inputs #321

Closed ocramz closed 3 months ago

ocramz commented 9 months ago

related : #8

closes #170

ocramz commented 9 months ago

NB remember to import http-api-data for the decoding functionality : https://hackage.haskell.org/package/http-api-data

jfraudeau commented 8 months ago

Regarding path segment inputs, they are already decoded by WAI/Warp in Request.pathInfo. Same goes for queryParams

I believe #262 is fixed by #302

pbrinkmeier commented 3 months ago

I just created my first PR at #392 :)

Basically path segments, query parameters and form data are handled by warp and therefore already decoded when they are accessed by scotty actions. When using warp, path segements are ultimately handled by Network.HTTP.Types.decodePathSegmentsand parameters are handled by Network.HTTP.Types.parseQuery. Both of those call Network.HTTP.Types.urlDecode internally. I added some tests for that.

And like the other PR, I added a formData action that can decode records with FormData instances from http-api-data.