Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[HttpFoundation] Don’t check suffix on empty MIME type
  • Loading branch information
MatTheCat authored and nicolas-grekas committed Aug 20, 2025
commit 38166178f7dc15e0b6abff9bc83587e08e33c45c
6 changes: 2 additions & 4 deletions src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1259,8 +1259,8 @@ public function getFormat(?string $mimeType, bool $subtypeFallback = false): ?st
}
}

if (!$canonicalMimeType) {
$canonicalMimeType = $mimeType;
if (!$canonicalMimeType ??= $mimeType) {
return null;
}

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

/**
* Structured MIME suffix fallback formats
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabbot complained this line missed a dot, but given a real description can be found below I removed it.

*
* This mapping is used when no exact MIME match is found in $formats.
* It enables handling of types like application/soap+xml → 'xml'.
*
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,7 @@ public static function getFormatToMimeTypeMapProvider()
];
}

/**
* @dataProvider getFormatWithSubtypeFallbackProvider
*/
#[DataProvider('getFormatWithSubtypeFallbackProvider')]
public function testGetFormatFromMimeTypeWithSubtypeFallback($expectedFormat, $mimeTypes)
{
$request = new Request();
Expand Down
Loading