WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 6 years ago

Last modified 6 years ago

#22823 closed defect (bug) (fixed)

Texturize should handle apostrophes before primes

Reported by: nacin Owned by: wonderboymusic
Milestone: 4.0 Priority: normal
Severity: minor Version: 3.4.2
Component: Formatting Keywords: has-patch wptexturize needs-refresh
Focuses: Cc:

Description

Not sure if anyone else noticed this, but my recent post on make/core exhibited an odd bug in wptexturize() —

The new target for WordPress 3.5′s release is Monday

Note how that's a prime — ′ — rather than an apostrophe, ’.

Switching the rules seems to work without breaking any unit tests.

Attachments (2)

22823.diff (979 bytes) - added by nacin 8 years ago.
miqro-22823.patch (1.7 KB) - added by miqrogroove 6 years ago.
This should take care of it.

Download all attachments as: .zip

Change History (12)

@nacin
8 years ago

#1 @nacin
8 years ago

Initial unit test in [UT1168].

#2 @bradyvercher
8 years ago

  • Cc brady@… added

This appears to affect more than just this case. Apostrophe characters following numbers that should be converted to single right quotes are instead converted to prime:

'Uno es 1' => ‘Uno es 1′

Even a double quote following a number is converted to a double prime.

"Dos es 2" => “Dos es 2″

The trailing characters in both of those examples aren't quotes (′ and ″). Switching the rules for all those characters would seem to make the prime matching obsolete.

This caused issues for me because the web font I'm using doesn't have support for the prime character and it creates nasty rendering issues. Taking a quick look through the best selling fonts on Fontspring and popular fonts on Font Squirrel, the majority don't appear to have support for prime or double prime built in, either.

#3 @nacin
7 years ago

This appears to be fixed by a patch on #4539.

#4 @nacin
7 years ago

#26852 was marked as a duplicate.

#5 @nacin
7 years ago

  • Keywords wptexturize added

#6 @miqrogroove
7 years ago

Can we make this a duplicate of #4539?

#7 follow-up: @wonderboymusic
6 years ago

  • Keywords needs-refresh added

Broken tests with the patch:

1) Tests_Formatting_WPTexturize::test_minutes_seconds
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'9′'
+'9’'

/Users/scott/svn/wordpress-core-develop/tests/phpunit/tests/formatting/WPTexturize.php:141

2) Tests_Formatting_WPTexturize::test_apos_before_digits with data set #5 ('word \'99\'s word', 'word ’99′s word')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'word ’99′s word'
+'word ’99’s word'

/Users/scott/svn/wordpress-core-develop/tests/phpunit/tests/formatting/WPTexturize.php:290

3) Tests_Formatting_WPTexturize::test_apos_before_digits with data set #6 ('word \'99\'samsonite', 'word ’99′samsonite')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'word ’99′samsonite'
+'word ’99’samsonite'

/Users/scott/svn/wordpress-core-develop/tests/phpunit/tests/formatting/WPTexturize.php:290

4) Tests_Formatting_WPTexturize::test_single_prime with data set #1 ('word 99\'word', 'word 99′word')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'word 99′word'
+'word 99’word'

/Users/scott/svn/wordpress-core-develop/tests/phpunit/tests/formatting/WPTexturize.php:505

5) Tests_Formatting_WPTexturize::test_single_prime with data set #3 ('word99\'word', 'word99′word')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'word99′word'
+'word99’word'

/Users/scott/svn/wordpress-core-develop/tests/phpunit/tests/formatting/WPTexturize.php:505

@miqrogroove
6 years ago

This should take care of it.

#8 in reply to: ↑ 7 @miqrogroove
6 years ago

Replying to wonderboymusic:

Broken tests with the patch:

Thank you for testing. Just needed to filter out apostrophes at end of string. Patch refreshed.

#9 @wonderboymusic
6 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 28725:

wptexturize() should handle apostrophes before primes.

Props nacin, miqrogroove.
Fixes #22823.

#10 @wonderboymusic
6 years ago

  • Milestone changed from Future Release to 4.0
Note: See TracTickets for help on using tickets.