tornadoweb / tornadoweb/tornado
Broken routing for urlencoded paths
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 22.2k
- Forks
- 5.6k
- Avg merge
- 3h 42m
- Merged PRs (30d)
- 16
Description
self.request.path is the raw urlencoded path from the HTTP start line (i.e. it doesn't even normalize anything and takes whatever the client gives).
The router PathMatches uses this to match the path against this.
Having a route definition like:
application = Application([
(r"/(cn=.*)/", MainHandler),
])
fails for /cn%3Dfoo/ and /cn%3dfoo/ but not for /cn=foo/.
A workaround is:
application = Application([
(r"/(cn(?:=|%3D|%3d).*)/", MainHandler),
])
In general I think it's wrong that request.path contains the urlencoded form of the path. It should be decoded. But it's probably an issue for backwards compatibility?
At least the routing component could decode the path before applying it to the routes!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the router's PathMatches logic and the use of self.request.path, then reproduce routing for /cn=foo/, /cn%3Dfoo/, and /cn%3dfoo/. Done means the routing behavior for equivalent urlencoded paths is defined and covered consistently, while accounting for the request.path backwards-compatibility concern.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100