bug #39358 [HttpFoundation] fix parsing some special chars with HeaderUtils::parseQuery() (nicolas-grekas)

This PR was merged into the 5.2 branch.

Discussion
----------

[HttpFoundation] fix parsing some special chars with HeaderUtils::parseQuery()

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #39307
| License       | MIT
| Doc PR        | -

Same as #39357 for 5.2

Commits
-------

8682bdc521 [HttpFoundation] fix parsing some special chars with HeaderUtils::parseQuery()
This commit is contained in:
Fabien Potencier 2020-12-08 08:08:22 +01:00
commit fd34c9c22f
2 changed files with 2 additions and 1 deletions

View File

@ -228,7 +228,7 @@ class HeaderUtils
if (false === $i = strpos($k, '[')) {
$q[] = bin2hex($k).$v;
} else {
$q[] = substr_replace($k, bin2hex(substr($k, 0, $i)), 0, $i).$v;
$q[] = bin2hex(substr($k, 0, $i)).rawurlencode(substr($k, $i)).$v;
}
}

View File

@ -151,6 +151,7 @@ class HeaderUtilsTest extends TestCase
['a[b]=c', 'a%5Bb%5D=c'],
['a[b][c.d]=c', 'a%5Bb%5D%5Bc.d%5D=c'],
['a%5Bb%5D=c'],
['f[%2525][%26][%3D][p.c]=d', 'f%5B%2525%5D%5B%26%5D%5B%3D%5D%5Bp.c%5D=d'],
];
}