-
Notifications
You must be signed in to change notification settings - Fork 580
psgi env: fix double encoding of path parts #2239
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
base: main
Are you sure you want to change the base?
psgi env: fix double encoding of path parts #2239
Conversation
6ee9b93
to
670ea6d
Compare
t/mojo/request_cgi.t
Outdated
@@ -2,6 +2,7 @@ use Mojo::Base -strict; | |||
|
|||
use Test::More; | |||
use Mojo::Message::Request; | |||
use Mojo::Util 'encode', 'url_escape'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_NAME
set.