Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#30438 closed defect (bug) (fixed)

Home path can't contain regular expression special chars

Reported by: akirk's profile akirk Owned by: ocean90's profile ocean90
Milestone: 4.3 Priority: normal
Severity: minor Version: 2.0
Component: Rewrite Rules Keywords: has-patch
Focuses: Cc:

Description

Because $home_path is used within a preg_replace without being run through preg_quote if, for example, it contains a + then it won't get stripped properly and therefore no path on the site will work.

Attachments (8)

class_wp.diff (974 bytes) - added by akirk 9 years ago.
unit-test.diff (1.1 KB) - added by akirk 9 years ago.
30438.diff (2.5 KB) - added by akirk 9 years ago.
30438.1.diff (2.9 KB) - added by akirk 9 years ago.
30438.2.diff (2.9 KB) - added by akirk 9 years ago.
Improve according to Coding Standards
30438.3.diff (2.9 KB) - added by akirk 9 years ago.
30438.4.diff (3.2 KB) - added by akirk 9 years ago.
30438.5.diff (3.2 KB) - added by akirk 9 years ago.

Download all attachments as: .zip

Change History (18)

@akirk
9 years ago

#1 @akirk
9 years ago

  • Severity changed from normal to minor

Small explanation for my patch: the preg_quote could be applied at the variable definition but for code review reasons I'd suggest to make it obvious in the preg_replace that the variable used in the regular expression is quoted properly.

Last edited 9 years ago by akirk (previous) (diff)

#2 @johnbillion
9 years ago

  • Keywords has-patch added
  • Version changed from trunk to 2.0

#3 @johnbillion
9 years ago

  • Keywords needs-unit-tests added

Thanks. It'd be good to have a unit test here too.

@akirk
9 years ago

#4 @akirk
9 years ago

I have added 2 unit tests in rewrite.php. Maybe you'd wish to put merge them into one function and use a foreach loop to avoid code duplication.

#5 @akirk
9 years ago

  • Keywords needs-unit-tests removed

This ticket was mentioned in Slack in #core by akirk. View the logs.


9 years ago

@akirk
9 years ago

@akirk
9 years ago

@akirk
9 years ago

Improve according to Coding Standards

#7 @akirk
9 years ago

Added patch with improved code according to coding standards.

@akirk
9 years ago

@akirk
9 years ago

#8 @akirk
9 years ago

Changed the test to use the more common case of a dot in the homepath.

@akirk
9 years ago

#9 @ocean90
9 years ago

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

In 32708:

Parse request: Quote regular expression characters in home path.

Adds unit tests.

props akirk.
fixes #30438.

#10 @ocean90
9 years ago

  • Milestone changed from Awaiting Review to 4.3
Note: See TracTickets for help on using tickets.