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: |
|
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)
Change History (4)
comment:1
SergeyBiryukov — 3 months ago
- Milestone changed from Awaiting Review to 3.6
- Version changed from 3.5.1 to 1.5.2
stevenkword — 3 months ago
comment:2
stevenkword — 3 months ago
- 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.
comment:3
stevenkword — 3 months ago
- Cc stevenkword added
Note: See
TracTickets for help on using
tickets.

Related: [2609]