Skip to content

Commit af4323e

Browse files
minor symfony#61471 [HttpFoundation] Don’t check suffix on empty MIME type (MatTheCat)
This PR was squashed before being merged into the 7.4 branch. Discussion ---------- [HttpFoundation] Don’t check suffix on empty MIME type | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | N/A | License | MIT Fix tests from symfony#61267 (remaining failures unrelated). Commits ------- 3816617 [HttpFoundation] Don’t check suffix on empty MIME type
2 parents ecdaa20 + 3816617 commit af4323e

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)