Project

General

Profile

Actions

Bug #97263

open

findPageCandidatesOfMountPoint breaks slugs if mount points to a folder and slugs start with the same string

Added by Dominik Steinborn about 2 years ago. Updated 9 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
-
Start date:
2022-03-31
Due date:
% Done:

0%

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

Description

Example Configuration:

1 Site 1: www.example.com
2 --- Folder: "Example" with Slug: "/example"
3 ------- Page: "Example 1" with Slug: "/example-1"

4 Site 2: subdomain.example.com
5 --- Cross site mount: "Example mount" with slug "/example-mount" mounting folder 2

When a menu of subpages is generated for 5 the resulting url of mounted page 3 will be:
https://subdomain.example.com/example-mount/-1 instead of https://subdomain.example.com/example-mount/example-1

Reason:
In method findPageCandidatesOfMountPoint of core/Classes/Routing/PageRouter.php the $commonSlugPrefixOfMountedPage will be removed from $slugOfSubpage even if the mounted page is a folder or spacer.

// Rewrite the slug of the subpage to match the PageRouter matching again
// This is done by first removing the "common" prefix possibly provided by the Mounted Page
// But more importantly adding the $slugOfMountPoint of the MountPoint Page
$slugOfSubpage = $pageCandidate['slug'];
if ($mountedPage['doktype'] === 1 && $commonSlugPrefixOfMountedPage && strpos($slugOfSubpage, $commonSlugPrefixOfMountedPage) === 0) {
    $slugOfSubpage = substr($slugOfSubpage, strlen($commonSlugPrefixOfMountedPage));
}

Possible solution:
Check doktype of mounted page before removing $commonSlugPrefixOfMountedPage.


Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Bug #94963: PageRouter generates invalid URLs for access restricted mountpointsNew2021-08-23

Actions
Actions #1

Updated by Dominik Steinborn about 2 years ago

Example Configuration:

1 Site 1: www.example.com
2 --- Folder: "Example" with Slug: "/example"
3 ------- Page: "Example 1" with Slug: "/example-1"

4 Site 2: subdomain.example.com
5 --- Cross site mount: "Example mount" with slug "/example-mount" mounting folder 2

When a menu of subpages is generated for 5 the resulting url of mounted page 3 will be:
https://subdomain.example.com/example-mount/-1 instead of https://subdomain.example.com/example-mount/example-1

Reason:
In method findPageCandidatesOfMountPoint of core/Classes/Routing/PageRouter.php the $commonSlugPrefixOfMountedPage will be removed from $slugOfSubpage even if the mounted page is a folder or spacer.


// Rewrite the slug of the subpage to match the PageRouter matching again
// This is done by first removing the "common" prefix possibly provided by the Mounted Page
// But more importantly adding the $slugOfMountPoint of the MountPoint Page
$slugOfSubpage = $pageCandidate['slug'];
if ($commonSlugPrefixOfMountedPage && strpos($slugOfSubpage, $commonSlugPrefixOfMountedPage) === 0) {
    $slugOfSubpage = substr($slugOfSubpage, strlen($commonSlugPrefixOfMountedPage));
}

Possible solution:
Check doktype of mounted page before removing $commonSlugPrefixOfMountedPage.

Actions #2

Updated by Dominik Steinborn about 2 years ago

Dominik Steinborn wrote in #note-1:

Example Configuration:

1 Site 1: www.example.com
2 --- Folder: "Example" with Slug: "/example"
3 ------- Page: "Example 1" with Slug: "/example-1"

4 Site 2: subdomain.example.com
5 --- Cross site mount: "Example mount" with slug "/example-mount" mounting folder 2

When a menu of subpages is generated for 5 the resulting url of mounted page 3 will be:
https://subdomain.example.com/example-mount/-1 instead of https://subdomain.example.com/example-mount/example-1

Reason:
In method findPageCandidatesOfMountPoint of core/Classes/Routing/PageRouter.php the $commonSlugPrefixOfMountedPage will be removed from $slugOfSubpage even if the mounted page is a folder or spacer.
[...]

Possible solution:
Check doktype of mounted page before removing $commonSlugPrefixOfMountedPage.

This should be an edit of the issue text. The original issue text includes a modification I made in the code snippet which is not in the original code.

Actions #3

Updated by Oliver Hader over 1 year ago

  • Sprint Focus set to On Location Sprint
Actions #4

Updated by Oliver Hader over 1 year ago

  • Related to Bug #94963: PageRouter generates invalid URLs for access restricted mountpoints added
Actions #5

Updated by Benni Mack 9 months ago

  • Sprint Focus deleted (On Location Sprint)
Actions

Also available in: Atom PDF