Opened 12 years ago
Last modified 6 years ago
#25021 new defect (bug)
Improve sanitize_title_with_dashes % removal
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.5 |
Component: | Formatting | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
The current method of % removal involves placeholders to prevent stomping on escape sequences:
// Preserve escaped octets. $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title); // Remove percent signs that are not part of an octet. $title = str_replace('%', '', $title); // Restore octets. $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
This leads to sanitize_title_with_dashes('---aa---')
producing %aa
instead of just aa
.
Attachments (1)
Change History (7)
#3
follow-up:
↓ 5
@
12 years ago
I'm going to guess "very slightly slower" is insignificant enough to warrant this change? We've always suggested that sanitize_title() and friends are not light and thus should be avoided where possible anyway.
How might this affect sanitize_title_for_query() (as in, working with older slugs that don't sanitize the same way)?
#4
@
12 years ago
Related: ticket:14773:14
Note: See
TracTickets for help on using
tickets.
25021.negative-lookahead.diff replaces the placeholder system with a single regex with a negative lookahead. This fixes the issue, but is very slightly slower in my very limited testing.