Skip to content

Commit 53be869

Browse files
bug #54910 [HttpFoundation]  filter out empty HTTP header parts (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [HttpFoundation]  filter out empty HTTP header parts | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #54868 | License | MIT Commits ------- 7d6d8cd97f filter out empty HTTP header parts
2 parents e13c456 + fdd485e commit 53be869

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

HeaderUtils.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,11 @@ private static function groupParts(array $matches, string $separators, bool $fir
286286
}
287287

288288
foreach ($partMatches as $matches) {
289-
$parts[] = '' === $separators ? self::unquote($matches[0][0]) : self::groupParts($matches, $separators, false);
289+
if ('' === $separators && '' !== $unquoted = self::unquote($matches[0][0])) {
290+
$parts[] = $unquoted;
291+
} elseif ($groupedParts = self::groupParts($matches, $separators, false)) {
292+
$parts[] = $groupedParts;
293+
}
290294
}
291295

292296
return $parts;

Tests/AcceptHeaderTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public static function provideFromStringData()
4141
{
4242
return [
4343
['', []],
44+
[';;;', []],
45+
['0', [new AcceptHeaderItem('0')]],
4446
['gzip', [new AcceptHeaderItem('gzip')]],
4547
['gzip,deflate,sdch', [new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch')]],
4648
["gzip, deflate\t,sdch", [new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch')]],

0 commit comments

Comments
 (0)