8000 [HttpFoundation] Fix trailing space for mime-type with parameters · symfony/symfony@f4866bc · GitHub
[go: up one dir, main page]

Skip to content

Commit f4866bc

Browse files
author
Sascha Dens
committed
[HttpFoundation] Fix trailing space for mime-type with parameters
1 parent 303cae1 commit f4866bc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ public function getFormat($mimeType)
13261326
{
13271327
$canonicalMimeType = null;
13281328
if (false !== $pos = strpos($mimeType, ';')) {
1329-
$canonicalMimeType = substr($mimeType, 0, $pos);
1329+
$canonicalMimeType = trim(substr($mimeType, 0, $pos));
13301330
}
13311331

13321332
if (null === static::$formats) {

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ public function testGetFormatFromMimeTypeWithParameters()
323323
{
324324
$request = new Request();
325325
$this->assertEquals('json', $request->getFormat('application/json; charset=utf-8'));
326+
$this->assertEquals('json', $request->getFormat('application/json;charset=utf-8'));
327+
$this->assertEquals('json', $request->getFormat('application/json ; charset=utf-8'));
328+
$this->assertEquals('json', $request->getFormat('application/json ;charset=utf-8'));
326329
}
327330

328331
public function testGetFormatWithCustomMimeType()

0 commit comments

Comments
 (0)
0