diff --git a/src/Negotiation/Negotiator.php b/src/Negotiation/Negotiator.php index 40f10c4..02215ee 100644 --- a/src/Negotiation/Negotiator.php +++ b/src/Negotiation/Negotiator.php @@ -157,6 +157,10 @@ protected function parseParameters($value) foreach ($parts as $part) { $part = explode('=', $part); + if (2 !== count($part)) { + continue; + } + if ('q' !== $key = strtolower($part[0])) { $parameters[$key] = $part[1]; } diff --git a/tests/Negotiation/Tests/NegotiatorTest.php b/tests/Negotiation/Tests/NegotiatorTest.php index f859dca..27f26a6 100644 --- a/tests/Negotiation/Tests/NegotiatorTest.php +++ b/tests/Negotiation/Tests/NegotiatorTest.php @@ -274,6 +274,10 @@ public static function dataProviderForParseParameters() 'application/json;q=1.0', array(), ), + array( + 'application/json;foo', + array(), + ), ); } }