bug #13944 [HttpKernel] UriSigner::buildUrl - default params for http_build_query (Jakub Simon)

This PR was squashed before being merged into the 2.6 branch (closes #13944).

Discussion
----------

[HttpKernel] UriSigner::buildUrl - default params for http_build_query

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

UriSigner fail to verify hash when custom ini setting arg_separator.output is used.
It was introduced in https://github.com/symfony/symfony/pull/12574

Commits
-------

3d6933f [HttpKernel] UriSigner::buildUrl - default params for http_build_query
This commit is contained in:
Fabien Potencier 2015-03-17 13:54:34 +01:00
commit 7055091edc
2 changed files with 13 additions and 1 deletions

View File

@ -36,4 +36,16 @@ class UriSignerTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($signer->sign('http://example.com/foo?foo=bar&bar=foo') === $signer->sign('http://example.com/foo?bar=foo&foo=bar'));
}
public function testCheckWithDifferentArgSeparator()
{
$this->iniSet('arg_separator.output', '&');
$signer = new UriSigner('foobar');
$this->assertSame(
"http://example.com/foo?baz=bay&foo=bar&_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D",
$signer->sign('http://example.com/foo?foo=bar&baz=bay')
);
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay')));
}
}

View File

@ -92,7 +92,7 @@ class UriSigner
private function buildUrl(array $url, array $params = array())
{
ksort($params);
$url['query'] = http_build_query($params);
$url['query'] = http_build_query($params, '', '&');
$scheme = isset($url['scheme']) ? $url['scheme'].'://' : '';
$host = isset($url['host']) ? $url['host'] : '';