Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Mojo/Message/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ sub _parse_env {
$base->path->parse($value =~ m!/$! ? $value : "$value/");

# Remove SCRIPT_NAME prefix if necessary
$path->parts;
my $buffer = $path->to_string;
$value =~ s!^/|/$!!g;
$buffer =~ s!^/?\Q$value\E/?!!;
Expand Down
20 changes: 20 additions & 0 deletions t/mojo/request_cgi.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use Mojo::Base -strict;

use Test::More;
use Mojo::Message::Request;
use Mojo::Util qw(encode url_escape);

subtest 'Parse Lighttpd CGI environment variables and body' => sub {
my $req = Mojo::Message::Request->new;
Expand Down Expand Up @@ -124,6 +125,25 @@ subtest 'Parse CGI environment with maximum message size' => sub {
'right absolute URL';
};

subtest 'Parse CGI environment with SCRIPT_NAME set and path part with UTF-8 character' => sub {
my $req = Mojo::Message::Request->new;
my $script_name = '/app/';
my $path_stub = 'some/action/blub/';
my $part_utf8 = encode('utf-8', "\x{1d120}");
my $path = $path_stub.url_escape($part_utf8);
$req->parse({
CONTENT_LENGTH => 0,
PATH_INFO => '/'.$path_stub.$part_utf8,
REQUEST_URI => $script_name.$path,
QUERY_STRING => '',
REQUEST_METHOD => 'GET',
SCRIPT_NAME => $script_name,
HTTP_HOST => 'localhost:8080',
SERVER_PROTOCOL => 'HTTP/1.1'
});
is $req->url->path->to_string, $path, 'round tripping yields same path';
};

subtest 'Parse Apache CGI environment variables and body (file storage)' => sub {
local $ENV{MOJO_MAX_MEMORY_SIZE} = 10;
my $req = Mojo::Message::Request->new;
Expand Down
Loading