Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Query Parameters Are Duplicated #174

Closed
wants to merge 1 commit into from

2 participants

@dmw397

The query parameters in GET requests are being duplicated. For example, the URL:

http://www.example.com/?a=foo&b=bar

generates a parameter hash that looks like this:

{
a => ['foo', 'foo'],
b => ['bar', 'bar'],
}

The root of the problem seems to be that Mojo::Parameters::parse doesn't clear _string before parsing the input string. As a result, _string is parsed and the new query parameters are added to it instead of replacing it.

@kraih
Owner

This does not appear to be true.

perl -Mojo -E'a("/" => sub { $_[0]->render_text($_[0]->dumper($_[0]->req->url->query->to_hash)) })->start' get '/?a=foo&b=bar'

You also seem to have forgotten unit tests.

@kraih kraih closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 27, 2011
  1. @dmw397
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1  lib/Mojo/Parameters.pm
View
3  lib/Mojo/Parameters.pm
@@ -87,9 +87,10 @@ sub params {
sub parse {
my ($self, $string) = @_;
- $string = delete $self->{_string} unless defined $string;
+ $string = $self->{_string} unless defined $string;
# Clear
+ delete $self->{_string};
$self->params([]);
# Detect pair separator for reconstruction
Something went wrong with that request. Please try again.