From 246a31c42f85b7986cb67b9dba36e579da1fed33 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 7 May 2018 17:16:26 +0100 Subject: [PATCH] Issue #2971012 by Wim Leers, borisson_: ContentTypeHeaderMatcher should not run for DELETE requests --- core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php | 8 ++++---- .../Tests/Core/Routing/ContentTypeHeaderMatcherTest.php | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php b/core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php index 719eeb13289..7d66b50ecef 100644 --- a/core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php +++ b/core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php @@ -15,10 +15,10 @@ class ContentTypeHeaderMatcher implements FilterInterface { * {@inheritdoc} */ public function filter(RouteCollection $collection, Request $request) { - // The Content-type header does not make sense on GET requests, because GET - // requests do not carry any content. Nothing to filter in this case. Same - // for all other safe methods. - if ($request->isMethodSafe(FALSE)) { + // The Content-type header does not make sense on GET or DELETE requests, + // because they do not carry any content. Nothing to filter in this case. + // Same for all other safe methods. + if ($request->isMethodSafe(FALSE) || $request->isMethod('DELETE')) { return $collection; } diff --git a/core/tests/Drupal/Tests/Core/Routing/ContentTypeHeaderMatcherTest.php b/core/tests/Drupal/Tests/Core/Routing/ContentTypeHeaderMatcherTest.php index 87e3f3e6c94..777073ed03b 100644 --- a/core/tests/Drupal/Tests/Core/Routing/ContentTypeHeaderMatcherTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/ContentTypeHeaderMatcherTest.php @@ -61,6 +61,7 @@ class ContentTypeHeaderMatcherTest extends UnitTestCase { ['HEAD'], ['OPTIONS'], ['TRACE'], + ['DELETE'], ]; }