Skip to content

Commit

Permalink
[HttpFoundation] Fix trailing space for mime-type with parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Sascha Dens committed Nov 21, 2018
1 parent 303cae1 commit f4866bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -1326,7 +1326,7 @@ public function getFormat($mimeType)
{
$canonicalMimeType = null;
if (false !== $pos = strpos($mimeType, ';')) {
$canonicalMimeType = substr($mimeType, 0, $pos);
$canonicalMimeType = trim(substr($mimeType, 0, $pos));
}

if (null === static::$formats) {
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Expand Up @@ -323,6 +323,9 @@ public function testGetFormatFromMimeTypeWithParameters()
{
$request = new Request();
$this->assertEquals('json', $request->getFormat('application/json; charset=utf-8'));
$this->assertEquals('json', $request->getFormat('application/json;charset=utf-8'));
$this->assertEquals('json', $request->getFormat('application/json ; charset=utf-8'));
$this->assertEquals('json', $request->getFormat('application/json ;charset=utf-8'));
}

public function testGetFormatWithCustomMimeType()
Expand Down

0 comments on commit f4866bc

Please sign in to comment.