Skip to content

Commit ec7793a

Browse files
committed
filter out empty HTTP header parts
1 parent de16e21 commit ec7793a

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy