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 eae834aac8af..501e7b3941f2 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 7e9a9f44353f..5422c1eb93c7 100644 --- a/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php +++ b/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php @@ -332,6 +332,64 @@ public function checkRegExpRedirects(string $url, int $expectedStatusCode, strin 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 function samePathWithSameDomainT3TargetDataProvider(): array { return [