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.72k stars 134 forks source link

Routing does not match url-encoded path #262

Closed PaulRivier closed 8 months ago

PaulRivier commented 4 years ago

Hi there,

I can not find a way to match an URL encoded path such as /page/P%C3%A2tes It seems to fail with both capture pattern, placeholders and regex.

Is this a bug ?

chessai commented 4 years ago

Can you post your code?

On Sun, May 3, 2020, 6:01 AM PaulRivier notifications@github.com wrote:

Hi there,

I can not find a way to match an URL encoded path such as /page/P%C3%A2tes It seems to fail with both capture pattern, placeholders and regex.

Is this a bug ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/scotty-web/scotty/issues/262, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEOIX25U6EJDA5SMNMRVFPTRPVTLJANCNFSM4MYDXQWA .

PaulRivier commented 4 years ago

Hello, thank you for your quick reply.

I messed my test cases before posting my original message, sorry about that. This is a more proper report, thank you for caring.

This works and matches /page/Pâtes

get "/page/:page" $ do
  p <- param "page"
  servePage p

But I need to match the rest of the url after page, not only first segment, so /page/recette/Pâtes would match with path=recette/Pâtes. I could not find a clean way to get this behaviour, so I used the regex feature.

My regex is something like :

get (regex "^/page/(.+)")
  p <- param "1"
  servePage p

It does match correctly /page/Hello, but it is buggy on /page/Pâtes. Basically, it will only match "P".

Interestingly, if regexp ends with "$" (like "^/page/(.+)$"), it does not match at all accentuated words.

Maybe the regex feature has some issues with multibytes chars.

I would appreciate a lot to have a pattern to match the remaining of the path, like "/page/:~page" or so.

Thank you.

ocramz commented 11 months ago

@PaulRivier url-decoding parameters looks buggy indeed

ocramz commented 8 months ago

As pointed out by @jfraudeau this is indeed fixed by #302

PaulRivier commented 8 months ago

Thank you guys.

On Sun, Dec 17, 2023 at 5:19 PM Marco Z @.***> wrote:

Closed #262 https://github.com/scotty-web/scotty/issues/262 as completed.

— Reply to this email directly, view it on GitHub https://github.com/scotty-web/scotty/issues/262#event-11268857389, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIT5BNOHCP3YDVI3CBWTAYLYJ4LR5AVCNFSM4MYDXQWKU5DIOJSWCZC7NNSXTWQAEJEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW4OZRGEZDMOBYGU3TGOBZ . You are receiving this because you were mentioned.Message ID: @.***>