[wp-trac] [WordPress Trac] #18170: sanitize_title_with_dashes() don't strip out some special punctuation

WordPress Trac wp-trac at lists.automattic.com
Tue Jul 19 09:37:48 UTC 2011

#18170: sanitize_title_with_dashes() don't strip out some special punctuation
 Reporter:  husobj        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Permalinks    |    Version:
 Severity:  normal        |   Keywords:
 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

 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)

 "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:

Ticket URL: <http://core.trac.wordpress.org/ticket/18170>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list