8000 filter out empty HTTP header parts · symfony/symfony@7d6d8cd · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d6d8cd

Browse files
xabbuhnicolas-grekas
authored andcommitted
filter out empty HTTP header parts
1 parent de16e21 commit 7d6d8cd

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Symfony/Component/HttpFoundation/HeaderUtils.php

Lines changed: 5 additions & 1 deletion
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;

src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php

Lines changed: 2 additions & 0 deletions
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)
0