WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#16036 closed defect (bug) (duplicate)

A wide dash should be treated like a normal hyphen in permalink creation

Reported by: brianlayman Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.0.3
Component: Permalinks Keywords: has-patch
Focuses: Cc:

Description

I'm not sure how obvious this will be when viewed but the issue is that it is possible (through cut & paste perhaps) to have a long dash included in the title of a post. It actually looks better that way and doesn't seem to get url encoded. And it remains intact when the text is cleaned.

So if the blog is titled:
Grades 9 – 12: Math Foundational Skills

instead of
Grades 9 - 12: Math Foundational Skills

The url becomes:
grades-9-–-12-math-foundation-skills

Instead of
grades-9-12-math-foundation-skills

So slugs would do this on links and categories too. Anything that uses that same clean functionality.

Attachments (1)

16036.patch (916 bytes) - added by solarissmoke 3 years ago.
Replace m- and n-dashes with normal dashes in sanitize_title_with_dashes

Download all attachments as: .zip

Change History (13)

comment:1 brianlayman3 years ago

  • Summary changed from A wide dash should be treated like a norma hyphen in url shortening to A wide dash should be treated like a normal hyphen in url shortening

comment:2 brianlayman3 years ago

  • Summary changed from A wide dash should be treated like a normal hyphen in url shortening to A wide dash should be treated like a normal hyphen in permalink creation

comment:3 jane3 years ago

+1 for reducing em dashes/en dashes to normal spacing hyphens in URLs.

solarissmoke3 years ago

Replace m- and n-dashes with normal dashes in sanitize_title_with_dashes

comment:4 solarissmoke3 years ago

  • Keywords has-patch dev-feedback added

comment:5 nacin3 years ago

  • Keywords 3.2-early added; dev-feedback removed
  • Milestone changed from Awaiting Review to Future Release

We can't do this like that -- sanitize_title_with_dashes() needs to be frozen in time, it can't be made more restrictive without breaking other things.

MarkJaquith came up with an idea for an on-the-fly upgrade procedure that would allow us to make changes to a new function. I'll let him describe it further when this ticket becomes accepted in the future.

comment:6 brianlayman3 years ago

yeah I was wondering about that. I didn't see a good solution at the time when I submitted the ticket. Would love to hear Mark's idea...

comment:7 brianlayman3 years ago

<MarkJaquith> Upgrade on save. We make a new function that gets all the modifications to slug generation. For anything that gets slug history 301ing (like posts). But for parsing a request, we use the current function.

comment:8 johnbillion3 years ago

  • Cc johnbillion@… added

comment:9 husobj3 years ago

  • Cc ben@… added

comment:10 nacin3 years ago

  • Milestone changed from Future Release to 3.3

comment:11 wpdavis3 years ago

I've noticed problems with other special characters, such as curly quotes (’).

WordPress includes a curly single quote in this slug: http://bangordailynews.com/2011/07/26/news/bangor/umaine-student’s-graffiti-project-art-not-vandalism/

When I paste it into a textbox it turns into a symbol: http://bangordailynews.com/2011/07/26/news/bangor/umaine-student%E2%80%99s-graffiti-project-art-not-vandalism/

Seems to me curly quotes should be stripped out of slugs just like straight apostrophes and quotes.

I can submit a patch if desired.

comment:12 SergeyBiryukov3 years ago

  • Keywords 3.2-early removed
  • Milestone 3.3 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This is actually a duplicate of #10797 (it's about curly quotes, but also has a patch for ndash/mdash), which itself was closed as a duplicate of #9591.

However, I guess sanitize_title_with_dashes() is a more appropriate function for such replacements than remove_accents(), which handles i18n-related improvements.

So I suggest to reopen that ticket.

Note: See TracTickets for help on using tickets.