diff --git a/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php b/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php index 0d5f62fc7532..ec7a3000c26b 100644 --- a/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php +++ b/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php @@ -55,6 +55,10 @@ public function accepts($contentTypes) $types = (array) $contentTypes; foreach ($accepts as $accept) { + if ($accept && $pos = strpos($accept, ';')) { + $accept = trim(substr($accept, 0, $pos)); + } + if ($accept === '*/*' || $accept === '*') { return true; } @@ -86,6 +90,10 @@ public function prefers($contentTypes) $contentTypes = (array) $contentTypes; foreach ($accepts as $accept) { + if ($accept && $pos = strpos($accept, ';')) { + $accept = trim(substr($accept, 0, $pos)); + } + if (in_array($accept, ['*/*', '*'])) { return $contentTypes[0]; }