WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#23865 closed defect (bug) (fixed)

Trailing slash is not enforced when editing the path for a subdirectory site in multisite

Reported by: simonwheatley Owned by: jeremyfelt
Milestone: 4.2 Priority: normal
Severity: normal Version: 3.0
Component: Networks and Sites Keywords: has-patch dev-feedback needs-refresh
Focuses: multisite Cc:

Description

It is possible to edit an existing subdirectory site so that the path does not end in a trailing slash, this causes the subdirectory site in question to have an inaccessible home URL.

To reproduce:

  • Create a multisite network in subdirectory mode
  • Create a new subdirectory site
  • Visit the subdirectory site successfully
  • Edit the site to change the path so there is no trailing slash
  • You should be unable to visit the subdirectory site now

Attachments (3)

23865.diff (690 bytes) - added by simonwheatley 6 years ago.
Ensures trailing and prefixing slash on path
23865.tests.diff (1.4 KB) - added by simonwheatley 6 years ago.
New test method for multisite to test the path is correctly sanitised and slashed
23865.2.diff (657 bytes) - added by simonwheatley 6 years ago.
Use sanitize_title and manually add prefixing and trailing slash for subdir site path

Download all attachments as: .zip

Change History (17)

#1 @simonwheatley
6 years ago

  • Keywords has-patch dev-feedback needs-unit-tests added

#2 @johnbillion
6 years ago

Can the same thing can happen with the leading slash?

@simonwheatley
6 years ago

Ensures trailing and prefixing slash on path

#3 @simonwheatley
6 years ago

Good spot, yes it can. Even more terminal issues there.

Patch amended to also add a prefixing slash.

#4 @SergeyBiryukov
6 years ago

  • Version changed from trunk to 3.0

#5 @simonwheatley
6 years ago

Attaching a diff showing a different approach, this time I'm using sanitise title and then adding the slashes manually. This approach allows us to check for multiple slashes which might have been added as well.

Also attaching some tests for this issue.

My first unit tests for WordPress, so I'd welcome any feedback. :)

@simonwheatley
6 years ago

New test method for multisite to test the path is correctly sanitised and slashed

@simonwheatley
6 years ago

Use sanitize_title and manually add prefixing and trailing slash for subdir site path

#6 @johnbillion
6 years ago

  • Keywords needs-unit-tests removed

#7 @jeremyfelt
6 years ago

  • Milestone changed from Awaiting Review to Future Release

Related #18117 (almost duplicate). It would be good to make sure both of these solutions go hand in hand.

#8 @jeremyfelt
6 years ago

@simonwheatley - I have feedback on process. :) The new develop.svn repository allows for the creation of a single patch that includes both the src and tests changes. It's much easier to apply and test that. Just run svn diff from the root of develop.svn's trunk.

#9 @jeremyfelt
5 years ago

  • Component changed from Multisite to Networks and Sites
  • Focuses multisite added

#10 @jeremyfelt
5 years ago

  • Keywords needs-refresh added

I'd like to work on getting this in for 4.1. We should refresh the patch to match the unit test changes in #29896.

#11 @earnjam
5 years ago

18117.4.diff:ticket:18117 appears to solve the trailing slash problem described in this ticket.

#13 @jeremyfelt
4 years ago

  • Owner set to jeremyfelt
  • Resolution set to fixed
  • Status changed from new to closed

In 31155:

Enforce leading and trailing slashes on paths updated with update_blog_details()

In multisite, core expects the stored value for a site's path to have leading and trailing slashes. When these slashes are missing, it becomes impossible to visit the site.

This enforces proper /path/ creation in update_blog_details(), most likely used when updating an existing site through site-info.php.

Props earnjam, simonwheatley.

Fixes #18117. Fixes #23865.

#14 @jeremyfelt
4 years ago

  • Milestone changed from Future Release to 4.2
Note: See TracTickets for help on using tickets.