#18170 closed defect (bug) (duplicate)
sanitize_title_with_dashes() don't strip out some special punctuation
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Permalinks | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | ben@… |
Description
Found an issue where sanitize_title_with_dashes() doesn't strip out some 'special' punctuation.
In my example it wasn't stripping out long or em-dashes.
The em-dash got in there by copying and pasting from elsewhere and may happen frequently.
This didn't cause an issue directly in the browser as that was able to handle a long dash OK, but in using the permalink in another scenario it came through as encoded characters which messed up the link.
I could possible filter the encoding out before using it, but it would be better and safer if em-dashes got replaced by the sanitize_title_with_dashes() function (and sanitize_title if that doesn't already).
The other knock-on effect was that if there is an em-dash you end up with loads of hyphens in the slug.
For example:
"Biography - About Me" (with an em-dash not a hyphen)
Becomes:
"biography---about-me" (where the middle hyphen is actually an em-dash)
If your title uses a hyphen rather than em-dash it collapses fine:
"biography-about-me"

#16036