PerlDancer / PerlDancer/Dancer2

%2f in uri and PATH_INFO vs REQUEST_URI

Open
#1,050 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Perl
Stars
604
Forks
288
Avg merge
1d 5h
Merged PRs (30d)
5

Description

Dancer2 uses PATH_INFO to match routes (in Core::Route->match Core::Request->dispatch_path is called, which resolves to Plack::Request->path). This has the consquence that resources with a slash (encoded as %2f) are decoded before matching, as Plack decodes this: https://metacpan.org/pod/distribution/PSGI/PSGI/FAQ.pod#Why-is-PATH_INFO-URI-decoded. For other backends this is undefined, or dependent on server configuration (eg. http://httpd.apache.org/docs/2.2/mod/core.html#allowencodedslashes)

ergo: a route defined as

del '/:myvar' => sub {

and a request

DELETE '/test%2fvar'

will not match if using Plack as a backend and may or may not match using other backends.

In my opinion this should not be dependent on the backend; in this example they should match, and param('myvar') should return "test/var".

This can be achieved by using (through the dispathc path interface or another way) REQUEST_URI instead of PATH_INFO in Core::Route->match. This has the disadvantage that URI decoding of params becomes a Dancer2 responsibility.

Thoughts?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Core::Route->match and the Core::Request->dispatch_path path that resolves to Plack::Request->path. Compare the reported DELETE '/test%2fvar' behavior with PATH_INFO and REQUEST_URI, including the backend differences described in the issue. Done should mean the route behavior and param('myvar') result are defined consistently for encoded slashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.