Skip to content

Commit e347239

Browse files
committed
Merge branch '5.4' into 6.2
* 5.4: relax assertions for ICU 72.1 [Validator] Fix regression with class metadatada on parent classes [VarExporter] Fix exporting classes with __serialize() but not __unserialize() [HttpFoundation][HttpKernel] Fix deprecations when `Content-Type` is `null`
2 parents 80e2557 + 415a1f8 commit e347239

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public function prepare(Request $request): static
281281
$charset = $this->charset ?: 'UTF-8';
282282
if (!$headers->has('Content-Type')) {
283283
$headers->set('Content-Type', 'text/html; charset='.$charset);
284-
} elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) {
284+
} elseif (0 === stripos($headers->get('Content-Type') ?? '', 'text/') && false === stripos($headers->get('Content-Type') ?? '', 'charset')) {
285285
// add the charset
286286
$headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset);
287287
}

Tests/ResponseTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,16 @@ public function testContentTypeCharset()
537537
$this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type'));
538538
}
539539

540+
public function testContentTypeIsNull()
541+
{
542+
$response = new Response('foo');
543+
$response->headers->set('Content-Type', null);
544+
545+
$response->prepare(new Request());
546+
547+
$this->expectNotToPerformAssertions();
548+
}
549+
540550
public function testPrepareDoesNothingIfContentTypeIsSet()
541551
{
542552
$response = new Response('foo');

0 commit comments

Comments
 (0)