File tree 2 files changed +11
-1
lines changed
src/Symfony/Component/HttpFoundation
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -1347,7 +1347,7 @@ public static function getMimeTypes($format)
1347
1347
public function getFormat ($ mimeType )
1348
1348
{
1349
1349
if (false !== $ pos = strpos ($ mimeType , '; ' )) {
1350
- $ mimeType = substr ($ mimeType , 0 , $ pos );
1350
+ $ canonicalMimeType = substr ($ mimeType , 0 , $ pos );
1351
1351
}
1352
1352
1353
1353
if (null === static ::$ formats ) {
@@ -1358,6 +1358,9 @@ public function getFormat($mimeType)
1358
1358
if (in_array ($ mimeType , (array ) $ mimeTypes )) {
1359
1359
return $ format ;
1360
1360
}
1361
+ if (isset ($ canonicalMimeType ) && in_array ($ canonicalMimeType , (array ) $ mimeTypes )) {
1362
+ return $ format ;
1363
+ }
1361
1364
}
1362
1365
}
1363
1366
Original file line number Diff line number Diff line change @@ -342,6 +342,13 @@ public function testGetMimeTypesFromInexistentFormat()
342
342
$ this ->assertEquals (array (), Request::getMimeTypes ('foo ' ));
343
343
}
344
344
345
+ public function testGetFormatWithCustomMimeType ()
346
+ {
347
+ $ request = new Request ();
348
+ $ request ->setFormat ('custom ' , 'application/vnd.foo.api;myversion=2.3 ' );
349
+ $ this ->assertEquals ('custom ' , $ request ->getFormat ('application/vnd.foo.api;myversion=2.3 ' ));
350
+ }
351
+
345
352
public function getFormatToMimeTypeMapProvider ()
346
353
{
347
354
return array (
You can’t perform that action at this time.
0 commit comments