Project

General

Profile

Actions

Bug #89799

closed

Capture groups for regex redirects are not respected in target

Added by S P almost 5 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Site Handling, Site Sets & Routing
Target version:
-
Start date:
2019-11-29
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Steps to reproduce:

  1. Create a redirect
  2. source: for example #^/foo/(.*)#
  3. target: http://another.domain/$1
  4. go to your.domain/foo/bar
  5. Redirect is triggered but literally to to http://another.domain/$1

Expected result: Redirect is made to http://another.domain/bar

Parsing the capture groups is not simply defect but actually not implemented at all. I flagged this explicitly as a bug (not as a feature) however, because the documentation does not clearly state this limitation and the module and GUI clearly allow regex-enabled redirects, so everything is suggesting that this must work and the backend editors and developers are left alone wasting their time to find out the hard way that this is not working - which is clearly a bug then.


Related issues 1 (0 open1 closed)

Precedes TYPO3 Core - Bug #91796: Capture groups for regex redirects are not respected in target, when target starts with pathClosed2019-12-022019-12-02

Actions
Actions #1

Updated by S P almost 5 years ago

Forget a step to reproduce: enable the regex toggle in the redirect, obviously.

Actions #2

Updated by Riccardo De Contardi almost 5 years ago

  • Category set to Site Handling, Site Sets & Routing
Actions #3

Updated by Bastian Stargazer almost 5 years ago

Ah thats why! This behaviour drove me crazy few month back! I thought I was just to dumb to use the regexp here because it was not working at all.
Good to know that it is a bug. I hope it will work sometimes in the future, thanks for pointing that out.

Actions #4

Updated by Gerrit Code Review almost 5 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62781

Actions #5

Updated by Gerrit Code Review almost 5 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62781

Actions #6

Updated by Gerrit Code Review almost 5 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62781

Actions #7

Updated by Gerrit Code Review almost 5 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62781

Actions #8

Updated by Gerrit Code Review almost 5 years ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62884

Actions #9

Updated by Guido Schmechel almost 5 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #10

Updated by Gerrit Code Review almost 5 years ago

  • Status changed from Resolved to Under Review

Patch set 2 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62884

Actions #11

Updated by Guido Schmechel almost 5 years ago

  • Status changed from Under Review to Resolved
Actions #12

Updated by Benni Mack over 4 years ago

  • Status changed from Resolved to Closed
Actions #13

Updated by Armin Vieweg over 4 years ago

  • Precedes Bug #91796: Capture groups for regex redirects are not respected in target, when target starts with path added
Actions #14

Updated by Gerrit Hübbers about 4 years ago

Does not work for me on 9.5.22 when the source_path does not include the dollar sign.

  • Doesn't work: #^/foo(.*)#
  • Works: #^/foo(.*)$#

Tested with target https://www.example.com/angebot$1

Actions #15

Updated by Benjamin Eyring over 3 years ago

Hi all,

in file
typo3_src-10.4.18/typo3/sysext/redirects/Classes/Service/RedirectService.php

in line 217 one can see that the ceptureGroup Replacement is realised only for redirects to files, folders, external URLs. Not pages.

What is the reason for that decision?

Thx in advance and best regards,
Ben

Actions #17

Updated by Stefan Bürk about 3 years ago

Benjamin Eyring wrote in #note-15:

Hi all,

in file
typo3_src-10.4.18/typo3/sysext/redirects/Classes/Service/RedirectService.php

in line 217 one can see that the ceptureGroup Replacement is realised only for redirects to files, folders, external URLs. Not pages.

What is the reason for that decision?

Thx in advance and best regards,
Ben

That's not a question of a decision. The provided target is run through the LinkHandler stack to resolve the target. This returns different types of resolved targets.
Running any kind of capture group replacement does not make sense on resolved page type, as the returned url of a pages cannot have a capture group definition in it.

That was what I would say first. Thinking about it, it could be a shortcut page with an redirect, which holds an capture group. Which is another point. Was that your usecase
why you asked why it was not done for pages ?

Actions

Also available in: Atom PDF