Skip to content

Commit

Permalink
Fix encoding of generated query strings
Browse files Browse the repository at this point in the history
Plus signs should not be encoded as spaces, as this will mangle the
values during server processing.

Fixes #605
  • Loading branch information
shadowhand committed Feb 1, 2017
1 parent 3859d43 commit 0fae187
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Tool/QueryBuilderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ trait QueryBuilderTrait
*/
protected function buildQueryString(array $params)
{
return http_build_query($params, null, '&');
return http_build_query($params, null, '&', \PHP_QUERY_RFC3986);
}
}
3 changes: 2 additions & 1 deletion test/src/Tool/QueryBuilderTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public function testBuildQueryString()
$params = [
'a' => 'foo',
'b' => 'bar',
'c' => '+',
];

$query = $this->buildQueryString($params);

$this->assertSame('a=foo&b=bar', $query);
$this->assertSame('a=foo&b=bar&c=%2B', $query);
}
}

0 comments on commit 0fae187

Please sign in to comment.