WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#7486 closed enhancement (fixed)

When looking for rewrite rules matches, change preg_match start/end character from ! to % or #

Reported by: aesqe Owned by: jacobsantos
Milestone: 2.8 Priority: lowest
Severity: trivial Version: 2.6
Component: General Keywords: has-patch commit
Focuses: Cc:

Description

In classes.php, around line 100 (lines 104 and 105 in WP 2.6, class WP) when trying to find rewrite rule matches, ! (exclamation mark) is used as start/end for regexp in the preg_match function. Should be changed to % or # to enable use of, for example, (?!) in rules.

Attachments (2)

7486.r10258.diff (595 bytes) - added by jacobsantos 5 years ago.
Patch is based off of r10258
7486.diff (559 bytes) - added by jacobsantos 5 years ago.
Patch based off of 10569 that uses '#' instead of '!'

Download all attachments as: .zip

Change History (9)

jacobsantos5 years ago

Patch is based off of r10258

comment:1 jacobsantos5 years ago

  • Keywords has-patch commit needs-testing added; regexp rewrite rules removed
  • Milestone changed from 2.9 to 2.8

Has patch, sending to 2.8.

comment:2 follow-up: DD325 years ago

  • Keywords needs-patch added; has-patch commit needs-testing removed
  • Version set to 2.6

preg_quote() is not the answer, that escapes all content within it, so as to render any rules useless.

would anyone have a need to use # in a rewrite rule?

comment:3 in reply to: ↑ 2 mrmist5 years ago

Replying to DD32:

would anyone have a need to use # in a rewrite rule?

Only if you were doing non-escaped redirection on an anchor. I guess it would be pretty rare.

comment:4 DD325 years ago

Only if you were doing non-escaped redirection on an anchor. I guess it would be pretty rare.

Does the Anchor even get sent -to- the server? I dont think it does?

Eitherway, It needs to use something as a delim. I would think # wouldnt be used within a URL (assuming its not sent to the server, and i'm pretty sure it isnt) in order to prevent confusing browsers, else it'd have to be escaped.. and that would just be plain ugly..

jacobsantos5 years ago

Patch based off of 10569 that uses '#' instead of '!'

comment:5 jacobsantos5 years ago

  • Keywords has-patch commit added; needs-patch removed

comment:6 jacobsantos5 years ago

  • Owner changed from anonymous to jacobsantos

comment:7 westi5 years ago

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

(In [10573]) Use # as the delimiter for preg_match in rewrite rules to allow them to contain !. Fixes #7486 props jacobsantos.

Note: See TracTickets for help on using tickets.