diff --git a/core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php b/core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php
index b782d9af6271b0dca7aa6ffdb85168d5448ea03c..beb988f6ebe329e84b2ddee621b01702a5aee840 100644
--- a/core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php
+++ b/core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php
@@ -25,7 +25,7 @@ public function filter(RouteCollection $collection, Request $request) {
     $format = $request->getContentType();
 
     foreach ($collection as $name => $route) {
-      $supported_formats = array_filter(explode('|', $route->getRequirement('_content_type_format')));
+      $supported_formats = array_filter(explode('|', $route->getRequirement('_content_type_format') ?? ''));
       if (empty($supported_formats)) {
         // No restriction on the route, so we move the route to the end of the
         // collection by re-adding it. That way generic routes sink down in the
diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php
index fb59cf562f9a189e696bf98ad94bae402ef7cef6..b3733e4ec87e3d9fcdbc89e79742eb2549237f4c 100644
--- a/core/modules/rest/src/Plugin/views/display/RestExport.php
+++ b/core/modules/rest/src/Plugin/views/display/RestExport.php
@@ -383,10 +383,11 @@ public function collectRoutes(RouteCollection $collection) {
    *   TRUE, when the view should override the given route.
    */
   protected function overrideApplies($view_path, Route $view_route, Route $route) {
-    $route_formats = explode('|', $route->getRequirement('_format'));
-    $view_route_formats = explode('|', $view_route->getRequirement('_format'));
+    $route_has_format = $route->hasRequirement('_format');
+    $route_formats = $route_has_format ? explode('|', $route->getRequirement('_format')) : [];
+    $view_route_formats = $view_route->hasRequirement('_format') ? explode('|', $view_route->getRequirement('_format')) : [];
     return $this->overrideAppliesPathAndMethod($view_path, $view_route, $route)
-      && (!$route->hasRequirement('_format') || array_intersect($route_formats, $view_route_formats) != []);
+      && (!$route_has_format || array_intersect($route_formats, $view_route_formats) != []);
   }
 
   /**
diff --git a/core/modules/system/tests/modules/accept_header_routing_test/src/Routing/AcceptHeaderMatcher.php b/core/modules/system/tests/modules/accept_header_routing_test/src/Routing/AcceptHeaderMatcher.php
index a90d4f4607c8ad527f86e95834aa4303b7b3f38a..ee4c013b69eb7002dff1eed3d089a11df2c7e252 100644
--- a/core/modules/system/tests/modules/accept_header_routing_test/src/Routing/AcceptHeaderMatcher.php
+++ b/core/modules/system/tests/modules/accept_header_routing_test/src/Routing/AcceptHeaderMatcher.php
@@ -24,7 +24,7 @@ public function filter(RouteCollection $collection, Request $request) {
 
     foreach ($collection as $name => $route) {
       // _format could be a |-delimited list of supported formats.
-      $supported_formats = array_filter(explode('|', $route->getRequirement('_format')));
+      $supported_formats = array_filter(explode('|', $route->getRequirement('_format') ?? ''));
 
       if (empty($supported_formats)) {
         // No format restriction on the route, so it always matches. Move it to