diff --git a/typo3/sysext/redirects/Tests/Functional/Service/Fixtures/RedirectService_regexp.csv b/typo3/sysext/redirects/Tests/Functional/Service/Fixtures/RedirectService_regexp.csv index eae834aac8af53173aeb3ff4d21c175d9869b484..501e7b3941f2266e771f52f16eea47add17eddf0 100644 --- a/typo3/sysext/redirects/Tests/Functional/Service/Fixtures/RedirectService_regexp.csv +++ b/typo3/sysext/redirects/Tests/Functional/Service/Fixtures/RedirectService_regexp.csv @@ -20,3 +20,5 @@ sys_redirect,,,,,,,,,,, ,14,0,301,0,0,acme.com,#^/respect-keep-relative-target-([a-zA-Z]{1}[a-zA-Z0-9]+)\?param1=([a-zA-Z]{1}[a-zA-Z0-9]+)$#,/$1/$2,1,1,1 ,15,0,301,0,0,acme.com,#^/other-relative-target-with-unsafe-capture-group-(.*)#,/offer-$1,1,1,0 ,16,0,301,0,0,acme.com,#^/other-redirect-with-unsafe-capture-group-(.*)#,https://anotherdomain.com/offer$1,1,1,0 +# * @see https://forge.typo3.org/issues/101739 +,17,0,301,0,0,acme.com,#^/regexp-respect-get-parameter$#,https://anotherdomain.com/regexp-respect-get-parameter,1,1,0 diff --git a/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php b/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php index 4edbeb5ef7dacc6ccab658f06d7c4fea599bc87d..a2640975718daf0b38b5a23320ad4983c6ab0089 100644 --- a/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php +++ b/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php @@ -337,6 +337,64 @@ final class RedirectServiceTest extends FunctionalTestCase self::assertEquals($expectedRedirectUri, $response->getHeader('location')[0]); } + /** + * @test + * @see https://forge.typo3.org/issues/101739 + */ + public function regexpWithNoParamRegexpAndRespectingGetParameteresIssuesNotFoundStatusIfParamsAreGivenInUrl(): void + { + $url = 'https://acme.com/regexp-respect-get-parameter?param1=value1'; + $expectedStatusCode = 404; + $this->importCSVDataSet(__DIR__ . '/Fixtures/RedirectService_regexp.csv'); + $this->writeSiteConfiguration( + 'acme-com', + $this->buildSiteConfiguration(1, 'https://acme.com/') + ); + $this->setUpFrontendRootPage( + 1, + ['typo3/sysext/redirects/Tests/Functional/Service/Fixtures/Redirects.typoscript'] + ); + + $response = $this->executeFrontendSubRequest( + new InternalRequest($url), + null, + false + ); + self::assertSame($expectedStatusCode, $response->getStatusCode()); + } + + /** + * @test + * @see https://forge.typo3.org/issues/101739 + */ + public function regexpWithNoParamRegexpAndRespectingGetParameteresRedirectsIfNoParamsAreGiven(): void + { + $url = 'https://acme.com/regexp-respect-get-parameter'; + $expectedStatusCode = 301; + $expectedRedirectUid = 17; + $expectedRedirectUri = 'https://anotherdomain.com/regexp-respect-get-parameter'; + $this->importCSVDataSet(__DIR__ . '/Fixtures/RedirectService_regexp.csv'); + $this->writeSiteConfiguration( + 'acme-com', + $this->buildSiteConfiguration(1, 'https://acme.com/') + ); + $this->setUpFrontendRootPage( + 1, + ['typo3/sysext/redirects/Tests/Functional/Service/Fixtures/Redirects.typoscript'] + ); + + $response = $this->executeFrontendSubRequest( + new InternalRequest($url), + null, + false + ); + self::assertSame($expectedStatusCode, $response->getStatusCode()); + self::assertIsArray($response->getHeader('X-Redirect-By')); + self::assertIsArray($response->getHeader('location')); + self::assertSame('TYPO3 Redirect ' . $expectedRedirectUid, $response->getHeader('X-Redirect-By')[0]); + self::assertSame($expectedRedirectUri, $response->getHeader('location')[0]); + } + public static function samePathWithSameDomainT3TargetDataProvider(): array { return [