From 00decdf5e9d1e679719204a97db60eeee1c36b67 Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Mon, 23 Aug 2021 20:31:30 +0200
Subject: [PATCH] [BUGFIX] Revert "Remove prefixed scriptName from urlPath in
 PageRouter"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit e2e59fb3db537bc7b2c0baa00267edfdd415035c due
to certain incompatibilities with direct "index.php" calls in
certain server setups.

Change-Id: I980feb08f3a507d51ad059763748ee64752aa9a3
Resolves: #94968
Reverts: #94537
Releases: master, 10.4, 9.5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70694
Tested-by: core-ci <typo3@b13.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 .../core/Classes/Routing/PageRouter.php       |  2 +-
 .../PageTypeDecoratorTest.php                 |  8 +-------
 .../Framework/Builder/Builder.php             | 19 -------------------
 3 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/typo3/sysext/core/Classes/Routing/PageRouter.php b/typo3/sysext/core/Classes/Routing/PageRouter.php
index b89eb4be7654..4f70dfc2cf64 100644
--- a/typo3/sysext/core/Classes/Routing/PageRouter.php
+++ b/typo3/sysext/core/Classes/Routing/PageRouter.php
@@ -147,7 +147,7 @@ class PageRouter implements RouterInterface
             if ($normalizedParams instanceof NormalizedParams) {
                 $scriptName = ltrim($normalizedParams->getScriptName(), '/');
                 if ($scriptName !== '' && strpos($urlPath, $scriptName) !== false) {
-                    $urlPath = str_replace('/' . $scriptName, '', $urlPath);
+                    $urlPath = str_replace($scriptName, '', $urlPath);
                 }
             }
         }
diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/EnhancerSiteRequest/PageTypeDecoratorTest.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/EnhancerSiteRequest/PageTypeDecoratorTest.php
index 2c4b6fa883dd..3c2f1cd76d17 100644
--- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/EnhancerSiteRequest/PageTypeDecoratorTest.php
+++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/EnhancerSiteRequest/PageTypeDecoratorTest.php
@@ -94,17 +94,11 @@ class PageTypeDecoratorTest extends AbstractEnhancerSiteRequestTest
                         )
                     )
             ;
-
             $testSets = array_merge(
                 $testSets,
-                [
-                    $testSetForPageContainingIndexInSlug->describe() => [
-                        $testSetForPageContainingIndexInSlug,
-                    ],
-                ],
+                [$testSetForPageContainingIndexInSlug->describe() => [$testSetForPageContainingIndexInSlug]]
             );
         }
-
         return $testSets;
     }
 
diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/Builder.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/Builder.php
index 8c3ad7b7d37d..05daa95b18d3 100644
--- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/Builder.php
+++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/Builder.php
@@ -126,16 +126,6 @@ class Builder
                 'menu.json' => 10,
             ],
         ];
-        $multipleTypesConfigurationDotPhp = [
-            'type' => 'PageType',
-            'default' => '.php',
-            'index' => 'index',
-            'map' => [
-                '.php' =>  0,
-                'menu.json' =>  10,
-                '.xml' => 20
-            ],
-        ];
 
         return [
             PageTypeDeclaration::create('null ".html"')
@@ -166,15 +156,6 @@ class Builder
                 ->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'])),
         ];
     }
 
-- 
GitLab