WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#32729 new defect (bug)

WP sanitize + (plus) and other mathematic symbols as nothing instead of dash separator

Reported by: thomask Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.3
Component: Formatting Keywords:
Focuses: Cc:

Description

If title contains e.g. plus symbol (e.g. title is "1+1=2", it creates slug 112, instead of 1-1-2. (and than it brings the other bug reported by me 8 years ago, that is just being to repair - #5305)

IMO such mathematical symbols should be considered as word separator (btw "apple+bannana" is converted to "applebannana"), so replaced by dash by default

Attachments (2)

34182.diff (1.5 KB) - added by jgrodel 3 years ago.
34182-2.diff (960 bytes) - added by jgrodel 3 years ago.

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
3 years ago

  • Component changed from General to Formatting

This ticket was mentioned in Slack in #core by swissspidy. View the logs.


3 years ago

#4 @jorbin
3 years ago

  • Milestone changed from Awaiting Review to Future Release

@jgrodel
3 years ago

#5 @jgrodel
3 years ago

Here's a quick patch for removing + and = from post slugs instead of replacing it with -. % is already removed. There's a line in there specifically replacing times with an x (included below). Might want to change that too?

                // Convert times to x
                $title = str_replace( '%c3%97', 'x', $title );

(WCUS)

@jgrodel
3 years ago

#6 @jgrodel
3 years ago

Oops. It's already doing this. Someone taught me how to run the tests. Then I fixed the tests. The tests seem to show that + and = were already being stripped instead of replaces by dashes. Uploaded the diff in case you want to use the tests.

Note: See TracTickets for help on using tickets.