Make WordPress Core

Opened 10 months ago

Closed 9 months ago

Last modified 9 months ago

#64089 closed defect (bug) (fixed)

Post titles containing non-breaking hyphens are not sanitized

Reported by: patpiwo Owned by: westonruter
Priority: normal Milestone: 6.9
Component: Formatting Version: 4.5
Severity: trivial Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

The sanitize_title_with_dashes function is lacking sanitization of non-breaking hyphens.

Attachments (1)

64089.diff (1008 bytes ) - added by patpiwo 10 months ago.

Download all attachments as: .zip

Change History (11)

@patpiwo
10 months ago

This ticket was mentioned in PR #10204 on WordPress/wordpress-develop by @patpiwo.


10 months ago
#1

Adds URL-encoded non-breaking hyphen () to the list of characters converted to regular hyphens in sanitize_title_with_dashes()

Fixes ticket #64089

Trac ticket:

#2 follow-up: @westonruter
9 months ago

  • Keywords needs-unit-tests added
  • Milestone Awaiting Review6.9

Thanks for opening this and for the PR!

I'm curious how you encountered this issue? Would there be other hyphen-like characters which would be suitable for turning into hyphens?

#4 @westonruter
9 months ago

  • Owner set to westonruter
  • Status newreviewing

#5 in reply to: ↑ 2 @patpiwo
9 months ago

Replying to westonruter:

Thanks for opening this and for the PR!

I'm curious how you encountered this issue? Would there be other hyphen-like characters which would be suitable for turning into hyphens?

Thanks for your quick feedback!

I encountered the issue when a user used the non-breaking hyphen in their post title. The non-breaking hyphen was used within a hyphenated product name which I assume they didn't want broken between lines. I'm guessing they copied it from some sort of marketing material but I'm not really sure.

As far as other hyphens go, I don't know if I have the knowlege to answer that question. I see 13 different characters listed under dash punctuation and I'm hesitant to broaden the scope of this fix unecessarily without knowing which dashes are common enough to be covered. If you have insight into this feel free to suggest or make any changes.

Last edited 9 months ago by patpiwo (previous) (diff)

@westonruter commented on PR #10204:


9 months ago
#6

I wanted to take this as an opportunity to improve maintenance of this going forward so I've added ff2d2a7. This is begging for a review from @dmsnell!

#7 @westonruter
9 months ago

  • Keywords has-unit-tests added; needs-unit-tests removed
  • Version trunk4.5

Follow-up to [18705] (5c6b6c0), [36775] (13e409a).

See #31790, #10797.

#8 @westonruter
9 months ago

  • Resolutionfixed
  • Status reviewingclosed

In 61061:

Formatting: Replace non-breaking hyphens (U+2011) with hyphens in sanitize_title_with_dashes().

Developed in https://github.com/WordPress/wordpress-develop/pull/10204

Follow-up to [18705], [36775].

Props patpiwo, westonruter, dmsnell.
See #31790, #10797.
Fixes #64089.

#9 @westonruter
9 months ago

Follow-up ticket to improve robustness: #64151

@westonruter commented on PR #10204:


9 months ago
#10

Committed in r61061

Note: See TracTickets for help on using tickets.