Skip to content

Commit 3816617

Browse files
MatTheCatnicolas-grekas
authored andcommitted
[HttpFoundation] Don’t check suffix on empty MIME type
1 parent d46df40 commit 3816617

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,8 +1259,8 @@ public function getFormat(?string $mimeType, bool $subtypeFallback = false): ?st
12591259
}
12601260
}
12611261

1262-
if (!$canonicalMimeType) {
1263-
$canonicalMimeType = $mimeType;
1262+
if (!$canonicalMimeType ??= $mimeType) {
1263+
return null;
12641264
}
12651265

12661266
if (str_starts_with($canonicalMimeType, 'application/') && str_contains($canonicalMimeType, '+')) {
@@ -1964,8 +1964,6 @@ protected static function initializeFormats(): void
19641964
}
19651965

19661966
/**
1967-
* Structured MIME suffix fallback formats
1968-
*
19691967
* This mapping is used when no exact MIME match is found in $formats.
19701968
* It enables handling of types like application/soap+xml → 'xml'.
19711969
*

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,7 @@ public static function getFormatToMimeTypeMapProvider()
538538
];
539539
}
540540

541-
/**
542-
* @dataProvider getFormatWithSubtypeFallbackProvider
543-
*/
541+
#[DataProvider('getFormatWithSubtypeFallbackProvider')]
544542
public function testGetFormatFromMimeTypeWithSubtypeFallback($expectedFormat, $mimeTypes)
545543
{
546544
$request = new Request();

0 commit comments

Comments
 (0)