Project

General

Profile

Actions

Bug #105971

closed

TypolinkTagSoftReferenceParser::parse does not match if extra parameters are part of url

Added by Soren Malling 26 days ago. Updated 8 days ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
Linkvalidator
Target version:
-
Start date:
2025-01-21
Due date:
% Done:

100%

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

Description

Using the b13/link2language package, to link across languages.

The links generated now and used for resolving now contains a extra L={language} parameter. The links are as such

<a href="t3://page?uid=2879&amp;L=1#23260">

Pattern used for matching in the TypolinkTagSoftReferenceParser::parse is

preg_match('/page\?uid=(\d+)#?(\d+)?/', $matches[1], $pageAndAnchorMatches)

This is the result of mathcing against a:

  • Link to page with L parameter: <a href="t3://page?uid=2881&amp;L=0"> => Matches the page uid. $pageAndAnchorMatches1 being 2881
  • Link to content element on page without L parameter: <a href="t3://page?uid=2879#23263"> => Matches the page uid and content element. $pageAndAnchorMatches1 being 2879 and $pageAndAnchorMatches2 being 23263
  • Link to content element on page with L parameter: <a href="t3://page?uid=2879&amp;L=1#23260"> => Matches the page uid. $pageAndAnchorMatches1 being 2879. No match to the content element reference. $pageAndAnchorMatches2 is empty

The expected behavior would be for the match to find a integer after uid and a integer after the hash and ignore other parameter not relevant for the parsing

External links
Somewhat related to the b13/link2language PR here: https://github.com/b13/link2language/pull/26


Files

Screenshot 2025-01-21 at 12.56.05.png (111 KB) Screenshot 2025-01-21 at 12.56.05.png URL without extra (L) parameter - three matches Soren Malling, 2025-01-21 12:35
Screenshot 2025-01-21 at 12.55.57.png (147 KB) Screenshot 2025-01-21 at 12.55.57.png URL with extra (L) parameter - two matches Soren Malling, 2025-01-21 12:35
Screenshot 2025-01-21 at 14.02.57.png (141 KB) Screenshot 2025-01-21 at 14.02.57.png New pattern matches links with extra patterns Soren Malling, 2025-01-21 13:03
Actions #1

Updated by Soren Malling 26 days ago

Asking ChatGPT for a helping hand to build a pattern "we" came up with this

https://regex101.com/r/MI3YOX/1

Pattern:

/page\?[^#]*\buid=(\d+)(?:[^#]*#(\d+))?/

Testcases:

t3://page?uid=2879&amp;L=1#23260
t3://page?uid=2879#23263
t3://page?uid=2881&amp;L=0

Returned values per testcase:

page?uid=2879&amp;L=1#23260
2879
23260

page?uid=2879#23263
2879
23263

page?uid=2881
2881

Actions #2

Updated by Soren Malling 26 days ago ยท Edited

Screenshot shows the linkvalidator accepting the link despite extra parameters and finding the deleted content element

Actions #3

Updated by Gerrit Code Review 26 days ago

  • Status changed from New to Under Review

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

Actions #4

Updated by Gerrit Code Review 9 days ago

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

Actions #5

Updated by Gerrit Code Review 8 days ago

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

Actions #6

Updated by Soren Malling 8 days ago

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

Also available in: Atom PDF