Problem/Motivation

A path /foo/foo-bar does not work correctly.

Steps to reproduce

Create a sub site with prefix foo. Than add site content with alias foo-bar.

Proposed resolution

Cut prefix after a / or if the path ends.

Issue fork sites-3601301

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

harlor created an issue. See original summary.

harlor’s picture

Assigned: harlor » hydra
Status: Active » Needs review

hydra made their first commit to this issue’s fork.

  • hydra committed e1280a72 on 1.x authored by harlor
    fix: #3601301 Path aliases that start with site a prefix break URLs
    
    By...
hydra’s picture

Status: Needs review » Fixed

Thanks @harlor — the fix looks right to me. I rebased onto current 1.x
and added test coverage so it stays fixed.

For the record, the bug is the missing path-segment boundary: str_starts_with('/subsite-bar', '/subsite')
is TRUE, so an alias like /subsite-bar on the default site was being
mistaken for the subsite prefix and routed into the subsite. Your change fixes
that by only matching on an exact prefix or one followed by a /.

I added a data-provider unit test on pathIsUsingPrefix() covering the exact
prefix, prefix + sub-path, and the boundary cases (/subsite-bar,
/subsiteother → not the prefix), plus a requestIsUsingPrefix()
regression for the reported alias case. They fail on the old str_starts_with()
and pass with your fix.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.