gorilla / mux

Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍

Home Page:https://gorilla.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] Wrong URL matching when url containing encoded slash (%2F)

gorshkov-leonid opened this issue · comments

I found a lot of similar issues here but with some resolution results. But I think I ought to create this issue because think problem is still actual.

I use /repositories/{id}/{branch} and /repositories/{id}/{branch}/files/structure. When I use branch feature/task1 (of cause, encoded as feature%2Ftask1) then it is not working.
I am aware of:

  • router.UseEncodedPath()
  • {branch:.+} pattern

router.UseEncodedPath() disables auto decoding of path components. In this case, I have to decode it additionally. It is not handy.

{branch:.+} brokes behavior. For example /repositories/{id}/{branch:.+} matches /repositories/123/feature%2Ftask1/files/structure. So this is wrong way.

I think that mux works incorrectly. In my opinion URL matching should be done before decoding path components.

commented

This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.