From ba70b39f261d42d747a323f3c9bd69b640e6c47b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto-Pekka=20Nyka=CC=88nen?= Date: Mon, 19 Sep 2022 13:42:36 +0300 Subject: [PATCH 1/3] UHF-5618: allow 'application/rss+xml; utf-8' content type to be handled properly --- src/HttpMiddleware/AssetHttpMiddleware.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/HttpMiddleware/AssetHttpMiddleware.php b/src/HttpMiddleware/AssetHttpMiddleware.php index 9d2bc92..080cd8d 100644 --- a/src/HttpMiddleware/AssetHttpMiddleware.php +++ b/src/HttpMiddleware/AssetHttpMiddleware.php @@ -97,10 +97,12 @@ private function isXmlResponse(Response $response) : bool { if (!$response->headers->has('content-type')) { return FALSE; } - return str_starts_with( - $response->headers->get('content-type') ?: '', - 'application/xml', - ); + foreach(['application/xml', 'application/rss+xml'] as $type) { + if (str_starts_with($response->headers->get('content-type'), $type)) { + return TRUE; + } + } + return FALSE; } /** From 3b9e90b50c18912c68651a0f1bc6f5322fc6a67d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto-Pekka=20Nyka=CC=88nen?= Date: Mon, 19 Sep 2022 13:46:16 +0300 Subject: [PATCH 2/3] UHF-5618: code fixes --- src/HttpMiddleware/AssetHttpMiddleware.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HttpMiddleware/AssetHttpMiddleware.php b/src/HttpMiddleware/AssetHttpMiddleware.php index 080cd8d..0f62ea3 100644 --- a/src/HttpMiddleware/AssetHttpMiddleware.php +++ b/src/HttpMiddleware/AssetHttpMiddleware.php @@ -97,7 +97,7 @@ private function isXmlResponse(Response $response) : bool { if (!$response->headers->has('content-type')) { return FALSE; } - foreach(['application/xml', 'application/rss+xml'] as $type) { + foreach (['application/xml', 'application/rss+xml'] as $type) { if (str_starts_with($response->headers->get('content-type'), $type)) { return TRUE; } From 0d1b532e6b28a036c3d8124102549cd4aea0e41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto-Pekka=20Nyka=CC=88nen?= Date: Tue, 20 Sep 2022 08:19:53 +0300 Subject: [PATCH 3/3] UHF-5618: updated test with missing xml header --- tests/src/Unit/AssetHttpMiddlewareTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/src/Unit/AssetHttpMiddlewareTest.php b/tests/src/Unit/AssetHttpMiddlewareTest.php index 4e6d61f..96f0d1a 100644 --- a/tests/src/Unit/AssetHttpMiddlewareTest.php +++ b/tests/src/Unit/AssetHttpMiddlewareTest.php @@ -69,6 +69,7 @@ public function xmlResponseProvider() : array { return [ ['application/xml'], ['application/xml; charset=utf-8'], + ['application/rss+xml; charset=utf-8'], ]; }