Skip to content

Commit ba17a35

Browse files
committed
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()
2 parents 778d6bc + ffeac06 commit ba17a35

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

HeaderUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public static function parseQuery(string $query, bool $ignoreBrackets = false, s
228228
if (false === $i = strpos($k, '[')) {
229229
$q[] = bin2hex($k).$v;
230230
} else {
231-
$q[] = substr_replace($k, bin2hex(substr($k, 0, $i)), 0, $i).$v;
231+
$q[] = bin2hex(substr($k, 0, $i)).rawurlencode(substr($k, $i)).$v;
232232
}
233233
}
234234

Tests/HeaderUtilsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public function provideParseQuery()
151151
['a[b]=c', 'a%5Bb%5D=c'],
152152
['a[b][c.d]=c', 'a%5Bb%5D%5Bc.d%5D=c'],
153153
['a%5Bb%5D=c'],
154+
['f[%2525][%26][%3D][p.c]=d', 'f%5B%2525%5D%5B%26%5D%5B%3D%5D%5Bp.c%5D=d'],
154155
];
155156
}
156157

0 commit comments

Comments
 (0)