diff --git a/HeaderUtils.php b/HeaderUtils.php index 3456edace..110896e17 100644 --- a/HeaderUtils.php +++ b/HeaderUtils.php @@ -286,7 +286,11 @@ private static function groupParts(array $matches, string $separators, bool $fir } foreach ($partMatches as $matches) { - $parts[] = '' === $separators ? self::unquote($matches[0][0]) : self::groupParts($matches, $separators, false); + if ('' === $separators && '' !== $unquoted = self::unquote($matches[0][0])) { + $parts[] = $unquoted; + } elseif ($groupedParts = self::groupParts($matches, $separators, false)) { + $parts[] = $groupedParts; + } } return $parts; diff --git a/Tests/AcceptHeaderTest.php b/Tests/AcceptHeaderTest.php index bf4582430..e972d714e 100644 --- a/Tests/AcceptHeaderTest.php +++ b/Tests/AcceptHeaderTest.php @@ -41,6 +41,8 @@ public static function provideFromStringData() { return [ ['', []], + [';;;', []], + ['0', [new AcceptHeaderItem('0')]], ['gzip', [new AcceptHeaderItem('gzip')]], ['gzip,deflate,sdch', [new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch')]], ["gzip, deflate\t,sdch", [new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch')]],