Skip to content
Snippets Groups Projects
Commit 39cb8bc5 authored by Andrey Tymchuk's avatar Andrey Tymchuk Committed by A.Tymchuk
Browse files

Issue #3180534 by rkostov, cgmonroe, gbyte, walkingdexter: Path processors too...

Issue #3180534 by rkostov, cgmonroe, gbyte, walkingdexter: Path processors too greedy with URLs ending with sitemap.xml
parent d0a1f5da
No related branches found
No related tags found
No related merge requests found
Pipeline #366632 passed with warnings
......@@ -5,6 +5,7 @@ namespace Drupal\simple_sitemap\PathProcessor;
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\simple_sitemap\Entity\SimpleSitemap;
use Symfony\Component\HttpFoundation\Request;
/**
......@@ -17,7 +18,7 @@ class SitemapPathProcessor implements InboundPathProcessorInterface, OutboundPat
*/
public function processInbound($path, Request $request) {
$args = explode('/', $path ?? '');
if (count($args) === 3 && $args[2] === 'sitemap.xml') {
if (count($args) === 3 && $args[2] === 'sitemap.xml' && SimpleSitemap::load($args[1])) {
$path = '/sitemaps/' . $args[1] . '/sitemap.xml';
}
......@@ -29,7 +30,7 @@ class SitemapPathProcessor implements InboundPathProcessorInterface, OutboundPat
*/
public function processOutbound($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL) {
$args = explode('/', $path ?? '');
if (count($args) === 4 && $args[3] === 'sitemap.xml') {
if (count($args) === 4 && $args[1] === 'sitemaps' && $args[3] === 'sitemap.xml') {
$path = '/' . $args[2] . '/sitemap.xml';
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment