diff --git a/Request.php b/Request.php index 391c59082..03c7e03a5 100644 --- a/Request.php +++ b/Request.php @@ -1051,23 +1051,31 @@ public function splitHttpAcceptHeader($header) } $values = array(); + $groups = array(); foreach (array_filter(explode(',', $header)) as $value) { // Cut off any q-value that might come after a semi-colon if (preg_match('/;\s*(q=.*$)/', $value, $match)) { - $q = (float) substr(trim($match[1]), 2); + $q = substr(trim($match[1]), 2); $value = trim(substr($value, 0, -strlen($match[0]))); } else { $q = 1; } + $groups[$q][] = $value; + } + + krsort($groups); + + foreach ($groups as $q => $items) { + $q = (float) $q; + if (0 < $q) { - $values[trim($value)] = $q; + foreach ($items as $value) { + $values[trim($value)] = $q; + } } } - arsort($values); - reset($values); - return $values; }