Skip to content

Commit

Permalink
Ignoring invalid parts in Accept: headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed Oct 6, 2014
1 parent 40122c6 commit 2bc499a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
7 changes: 6 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
ChangeLog
=========

3.0.2 (2014-10-06)
------------------

* When parsing `Accept:` headers, we're ignoring invalid parts. Before we
would throw a PHP E_NOTICE.

3.0.1 (2014-09-29)
------------------

* Minor change in unittests.


3.0.0 (2014-09-23)
------------------

Expand Down
11 changes: 10 additions & 1 deletion lib/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ static function negotiateContentType($acceptHeaderValue, array $availableOptions

foreach($proposals as $proposal) {

// Ignoring broken values.
if (is_null($proposal)) continue;

// If the quality is lower we don't have to bother comparing.
if ($proposal['quality'] < $lastQuality) {
continue;
Expand Down Expand Up @@ -205,7 +208,13 @@ private static function parseMimeType($str) {

// The first part is the mime-type.
$mimeType = array_shift($parts);
list($type, $subType) = explode('/', trim($mimeType));

$mimeType = explode('/', trim($mimeType));
if (count($mimeType)!==2) {
// Illegal value
return null;
}
list($type, $subType) = $mimeType;

foreach($parts as $part) {

Expand Down
2 changes: 1 addition & 1 deletion lib/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class Version {
/**
* Full version number
*/
const VERSION = '3.0.1';
const VERSION = '3.0.2';

}

0 comments on commit 2bc499a

Please sign in to comment.