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

Adds unit tests.

Props harrym, kurtpayne, miqrogroove.
Fixes #19308.

Built from https://develop.svn.wordpress.org/trunk@28719


git-svn-id: http://core.svn.wordpress.org/trunk@28533 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-06-10 02:18:15 +00:00
parent 12e7d6744b
commit 4666c1abe2

View File

@ -180,10 +180,10 @@ function wptexturize($text) {
// regular expressions // regular expressions
$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
// 9x9 (times) // 9x9 (times), but never 0x9999
if ( 1 === preg_match( '/(?<=\d)x\d/', $text ) ) { 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! // 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 );
} }
} }