Skip to content

Commit

Permalink
[BUGFIX] Remove prefixed scriptName from urlPath in PageRouter
Browse files Browse the repository at this point in the history
Remove resolved scriptName with leading slash from url in
PageRouter matchRequest method.

This prevent to change the url to a invalid url if
PageTypeSuffix Decorator with .php is used and a page slugs
ends in index.

Resolves: #94537
Releases: master, 10.4, 9.5
Change-Id: I5057bb6888c228a4ca5b53d363ecf1bc7a6af1c6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69854
Tested-by: core-ci <typo3@b13.com>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
sbuerk authored and bmack committed Aug 13, 2021
1 parent 99b134d commit e2e59fb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion typo3/sysext/core/Classes/Routing/PageRouter.php
Expand Up @@ -147,7 +147,7 @@ public function matchRequest(ServerRequestInterface $request, RouteResultInterfa
if ($normalizedParams instanceof NormalizedParams) {
$scriptName = ltrim($normalizedParams->getScriptName(), '/');
if ($scriptName !== '' && strpos($urlPath, $scriptName) !== false) {
$urlPath = str_replace($scriptName, '', $urlPath);
$urlPath = str_replace('/' . $scriptName, '', $urlPath);
}
}
}
Expand Down
Expand Up @@ -94,11 +94,17 @@ public function pageTypeDecoratorIndexCanBePartOfSlugDataProvider(): array
)
)
;

$testSets = array_merge(
$testSets,
[$testSetForPageContainingIndexInSlug->describe() => [$testSetForPageContainingIndexInSlug]]
[
$testSetForPageContainingIndexInSlug->describe() => [
$testSetForPageContainingIndexInSlug,
],
],
);
}

return $testSets;
}

Expand Down
Expand Up @@ -126,6 +126,16 @@ public function declarePageTypes(): array
'menu.json' => 10,
],
];
$multipleTypesConfigurationDotPhp = [
'type' => 'PageType',
'default' => '.php',
'index' => 'index',
'map' => [
'.php' => 0,
'menu.json' => 10,
'.xml' => 20
],
];

return [
PageTypeDeclaration::create('null ".html"')
Expand Down Expand Up @@ -156,6 +166,15 @@ public function declarePageTypes(): array
->withGenerateParameters(['&type=0'])
->withResolveArguments(['pageType' => 0])
->withVariables(Variables::create(['pathSuffix' => '/', 'index' => ''])),
PageTypeDeclaration::create('null ".php"')
->withConfiguration($multipleTypesConfigurationDotPhp)
->withResolveArguments(['pageType' => 0])
->withVariables(Variables::create(['pathSuffix' => '.php', 'index' => 'index'])),
PageTypeDeclaration::create('0 ".php"')
->withConfiguration($multipleTypesConfigurationDotPhp)
->withGenerateParameters(['&type=0'])
->withResolveArguments(['pageType' => 0])
->withVariables(Variables::create(['pathSuffix' => '.php', 'index' => 'index'])),
];
}

Expand Down

0 comments on commit e2e59fb

Please sign in to comment.