psgi env: fix double encoding of path parts#2239
psgi env: fix double encoding of path parts#2239sparrow2009 wants to merge 1 commit intomojolicious:mainfrom
Conversation
6ee9b93 to
670ea6d
Compare
t/mojo/request_cgi.t
Outdated
|
|
||
| use Test::More; | ||
| use Mojo::Message::Request; | ||
| use Mojo::Util 'encode', 'url_escape'; |
There was a problem hiding this comment.
We use the use Mojo::Util qw(...) style everywhere now.
Fix double encoding of path parts when parsing a PSGI env with a SCRIPT_NAME set. Make sure path is decoded and unescaped as expected by to_string. The test $env used in the regression test included is a stripped down version of the result of: use HTTP::Request::Common 'GET'; use HTTP::Message::PSGI 'req_to_psgi'; my $script_name = ...; my $path = ...; $env = req_to_psgi( GET( 'http://localhost:8080'.$script_name.$path ), SCRIPT_NAME => $script_name );
670ea6d to
26d373d
Compare
|
A final note: This is actually a downstream patch in order to handle a race condition that is built into Thus if one happens to call From reading the object construction examples listed in the synopsis of |
There was a problem hiding this comment.
Pull Request Overview
This PR addresses the double encoding issue of path parts when parsing a PSGI env with a SCRIPT_NAME set. The key changes include:
- Adding a test case that covers a UTF-8 path part scenario.
- Utilizing Mojo::Util’s encode and url_escape functions in tests.
- Invoking $path->parts in the request parser to address the encoding problem.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| t/mojo/request_cgi.t | New test for UTF-8 path parts and verification of roundtripping |
| lib/Mojo/Message/Request.pm | Adjusted environment parsing by calling $path->parts |
Comments suppressed due to low confidence (1)
lib/Mojo/Message/Request.pm:200
- Consider adding an inline comment explaining why calling $path->parts at this point fixes the double encoding issue. This will help future maintainers understand the intent behind the call.
$path->parts;
Fix double encoding of path parts when parsing a PSGI env with a
SCRIPT_NAMEset.