In wptexturize(), don't convert C-style hexadecimals to mathematical ×.

Adds unit tests.

Props harrym, kurtpayne, miqrogroove.
Fixes #19308.


git-svn-id: https://develop.svn.wordpress.org/trunk@28719 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2014-06-10 02:17:24 +00:00
parent f9bcf40db7
commit a66f776684
2 changed files with 23 additions and 3 deletions

View File

@ -180,10 +180,10 @@ function wptexturize($text) {
// regular expressions
$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
// 9x9 (times)
if ( 1 === preg_match( '/(?<=\d)x\d/', $text ) ) {
// 9x9 (times), but never 0x9999
if ( 1 === preg_match( '/(?<=\d)x-?\d/', $text ) ) {
// Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one!
$curl = preg_replace( '/\b(\d+)x(\d+)\b/', '$1&#215;$2', $curl );
$curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(-?\d[\d\.,]*)\b/', '$1&#215;$2', $curl );
}
}

View File

@ -780,10 +780,30 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
"12x34",
"12&#215;34",
),
array(
"-123x1=-123",
"-123&#215;1=-123",
),
array(
"-123x-1",
"-123&#215;-1",
),
array(
"0.675x1=0.675",
"0.675&#215;1=0.675",
),
array(
"9 x 9",
"9 x 9",
),
array(
"0x70",
"0x70",
),
array(
"3x2x1x0",
"3x2x1x0",
),
);
}