Query Parameters Are Duplicated #175

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@dmw397

When parsing incoming GET requests, the query parameters are stored twice. The problem is triggered in the _parse_env method in Mojo::Message::Request:

Line 284: if (my $value = $env->{REQUEST_URI}) { $url->parse($value) }
Line 287: if (my $value = $env->{QUERY_STRING}) { $url->query->parse($value) }

The parse method in line 284 invokes Mojo::Parameters->new with the query parameters as an argument, which stores the parameters as a string inside the Mojo::Parameters object. The query->parse method in line 287 invokes the Mojo::Parameters::parse method, which converts the string stored by the new method into an arrayref and then adds the query parameters to it. The result is that a query string like this:

a=foo&b=bar

ends up producing a parameter array like this:

[ 'a', 'foo', 'b', 'bar', 'a', 'foo', 'b', 'bar' ]

This pull request contains a fix to clear the existing query parameters before parsing new ones as well as a unit test for the problem.

@kraih
Owner

Thanks, applied.

@kraih kraih closed this Jun 29, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment