Review 13.4 Merged

89221[BUGFIX] Strip only existing prefix in PathUtility::stripPathSitePrefix()

Stefan Bürk CR +2 V +2 Normal +54 −27 updated 05/14/25, 07:23

Commit message

Current `PathUtility::stripPathSitePrefix()` implementation simple
stripped the length from `Environment::getPublicPath() . '/'` from
provided `$path`, even if `$path` never contained the public path
from the start aka path prefix leading to malformed path information
and other issues.

Second, even in case it has been stripped it does not deal with the
fact it could be that there are two `//` between the public path
prefix and the rest of the path, returning the stripped path with
and without a leading slash (`/`) which not every usage is aware of.

This change modifies the method to return the unmodifed `$path` if it
does not have the publicPath as prefix and otherwise strip the prefix
and removing eventually duplicated `/` when splitting the path.

Additionally, the stripped path is left-trimmed to ensure no leading
slash is returned.

Tests are added to check for the expected behaviour.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
  • Verified V +2 Done
    • Stefan Bürk +2
    • core-ci +1 CI

Issues 2

Files 2

Review log 45

  1. Stefan Bürk commented on patch set 1 04/24/25, 11:37

    Cherry Picked from branch main.
  2. core-ci voted on patch set 1 V +1 04/24/25, 11:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78118

  3. Stefan Bürk voted on patch set 1 CR +2 V +2 04/24/25, 11:46

  4. Stefan Bürk merged patch set 2 04/24/25, 11:46

  5. Stefan Bürk wrote 05/14/25, 07:23

    Created a revert of this change as Id46418eb2294ab38a280ed917abace312d0f203d