Opened 3 months ago

Last modified 3 months ago

#23587 new defect (bug)

url_to_postid() needs to use # or @ for preg_match start/end character

Reported by: coreygilmore Owned by:
Priority: normal Milestone: 3.6
Component: Rewrite Rules Version: 1.5.2
Severity: normal Keywords: has-patch
Cc: stevenkword

Description

url_to_postid() uses ! for the start/end characters of regular expressions, which doesn't allow you to use expressions containing !, like (?!negativelookahead).

The solution is to use preg_match("#^$match#", $request_match, $matches) or preg_match("@^$match@", $request_match, $matches)

See also: #7486 and WP::parse_request()

Attachments (1)

23587_regex_delimiters.patch (966 bytes) - added by stevenkword 3 months ago.

Download all attachments as: .zip

Change History (4)

  • Milestone changed from Awaiting Review to 3.6
  • Version changed from 3.5.1 to 1.5.2

Related: [2609]

  • Keywords has-patch added; needs-patch removed

Attached a patch that replaces the regular expression delimiters of "!" with "#" for an instance of preg_match(). I also noticed the same pattern with an instance of preg_replace() and performed the same substitution. This was done to allow for regular expressions containing the "!" character.

Last edited 3 months ago by stevenkword (previous) (diff)
  • Cc stevenkword added
Note: See TracTickets for help on using tickets.