Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/4702'
Browse files Browse the repository at this point in the history
  • Loading branch information
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/Header/Accept.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
class Accept extends AbstractAccept
{
/**
* @var string
*/
protected $regexAddType = '#^([a-zA-Z+-]+|\*)/(\*|[a-zA-Z0-9+-]+)$#';

/**
Expand Down Expand Up @@ -67,9 +70,9 @@ public function hasMediaType($type)
/**
* Parse the keys contained in the header line
*
* @param string $fieldValuePart
* @return \Zend\Http\Header\Accept\FieldValuePart\CharsetFieldValuePart
* @see \Zend\Http\Header\AbstractAccept::parseFieldValuePart()
* @param string $fieldValuePart
* @return FieldValuePart\AcceptFieldValuePart
* @see \Zend\Http\Header\AbstractAccept::parseFieldValuePart()
*/
protected function parseFieldValuePart($fieldValuePart)
{
Expand All @@ -87,7 +90,7 @@ protected function parseFieldValuePart($fieldValuePart)
}

if ($pos = strpos($fieldValuePart, '/')) {
$subtypeWhole = $format = $subtype = trim(substr($fieldValuePart, strpos($fieldValuePart, '/')+1));
$subtypeWhole = $format = $subtype = trim(substr($fieldValuePart, strpos($fieldValuePart, '/') + 1));
} else {
$subtypeWhole = '';
$format = '*';
Expand All @@ -96,19 +99,19 @@ protected function parseFieldValuePart($fieldValuePart)

$pos = strpos($subtype, '+');
if (false !== $pos) {
$format = trim(substr($subtype, $pos+1));
$format = trim(substr($subtype, $pos + 1));
$subtype = trim(substr($subtype, 0, $pos));
}

$aggregated = array(
'typeString' => trim($fieldValuePart),
'type' => $type,
'subtype' => $subtype,
'subtypeRaw' => $subtypeWhole,
'format' => $format,
'priority' => isset($params['q']) ? $params['q'] : 1,
'params' => $params,
'raw' => trim($raw)
'typeString' => trim($fieldValuePart),
'type' => $type,
'subtype' => $subtype,
'subtypeRaw' => $subtypeWhole,
'format' => $format,
'priority' => isset($params['q']) ? $params['q'] : 1,
'params' => $params,
'raw' => trim($raw),
);

return new FieldValuePart\AcceptFieldValuePart((object) $aggregated);
Expand Down

0 comments on commit 5c10b75

Please sign in to comment.