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

This commit is contained in:
Nicolas Grekas 2020-12-07 12:47:49 +01:00
parent ac9858b0c8
commit 8682bdc521
2 changed files with 2 additions and 1 deletions

View File

@ -228,7 +228,7 @@ class HeaderUtils
if (false === $i = strpos($k, '[')) { if (false === $i = strpos($k, '[')) {
$q[] = bin2hex($k).$v; $q[] = bin2hex($k).$v;
} else { } 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', 'a%5Bb%5D=c'],
['a[b][c.d]=c', 'a%5Bb%5D%5Bc.d%5D=c'], ['a[b][c.d]=c', 'a%5Bb%5D%5Bc.d%5D=c'],
['a%5Bb%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'],
]; ];
} }