Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router should use raw HTTP path for route matching #284

Open
weiwei-lin opened this issue Oct 23, 2019 · 5 comments
Open

Router should use raw HTTP path for route matching #284

weiwei-lin opened this issue Oct 23, 2019 · 5 comments

Comments

@weiwei-lin
Copy link

weiwei-lin commented Oct 23, 2019

At the moment, "/param1a%2fparam1b/tail" matches route "head/:param1/:param2/tail" instead of ":param1/tail". There's no way we can have a '/' in a URL param.

@DiegoZoracKy
Copy link

I just came here to open this same issue. It seems that %2F is being decoded to / before trying to match a route path. In that way the lib is not supporting a param value (correctly encoded) containing a forward slash.

@razonyang
Copy link
Contributor

razonyang commented Feb 29, 2020

EDIT:
There is a long standing issue of httprouter, see #55 and #209

@weiwei-lin @DiegoZoracKy
As the document mentioned, the named parameters(:name) match anything until the next '/' or the path end.
But catch-all parameter(*name) will match the anything until the end, you should use catch-all parameter instead.

Btw, it doesn't make sence that named parameters should match /, since head/:param1/tail and head/:param1/:param2/tail are conflicting.

@weiwei-lin
Copy link
Author

weiwei-lin commented Apr 8, 2021

you should use catch-all parameter instead.

Unfortunately, that only works if we only have encoded character in the last path component.
For example, there's still no way to match "head/a%2Fb/c%2Fd/tail" to "head/:param1/:param2/tail".
Even more, with the existing routing mechanism, there's no way to distinguish between "head/a%2Fb" and "head/a/b".

since head/:param1/tail and head/:param1/:param2/tail are conflicting

You are right. But my point was that

  1. /param1a%2fparam1b/tail will match "/:param1/:param2/tail" if that route exist, which is incorrect.
  2. /param1a%2fparam1b/tail will not match "/:param1/tail" if that route exist, which is also incorrect.

The whole point of doing URL escaping is because we don't want to treat the encoded characters as special characters. Using decoded path to perform routing defeats the whole purpose of URL escaping.

@halorium
Copy link

halorium commented Oct 2, 2021

I just updated #209 if it's helpful to you. I had to use a forked version with this change on a project due to the nature of the urls we had to deal with.

@darrenparkinson
Copy link

Also here looking for this. Any chance this might be added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants