[HttpFoundation] Fix trailing space for mime-type with parameters

This commit is contained in:
Sascha Dens 2018-11-21 13:53:33 +01:00
parent 303cae1fec
commit f4866bc371
2 changed files with 4 additions and 1 deletions

View File

@ -1326,7 +1326,7 @@ class Request
{
$canonicalMimeType = null;
if (false !== $pos = strpos($mimeType, ';')) {
$canonicalMimeType = substr($mimeType, 0, $pos);
$canonicalMimeType = trim(substr($mimeType, 0, $pos));
}
if (null === static::$formats) {

View File

@ -323,6 +323,9 @@ class RequestTest extends TestCase
{
$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()