When a hyphen `-` or double hyphen `--` was at the start or the end of a string, it wasn't texturized correctly.

Fixes #31030



git-svn-id: https://develop.svn.wordpress.org/trunk@31199 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2015-01-16 03:54:00 +00:00
parent d266ecd5b2
commit c8c8b66bae
2 changed files with 15 additions and 2 deletions

View File

@ -174,9 +174,9 @@ function wptexturize($text, $reset = false) {
// Dashes and spaces
$dynamic[ '/---/' ] = $em_dash;
$dynamic[ '/(?<=' . $spaces . ')--(?=' . $spaces . ')/' ] = $em_dash;
$dynamic[ '/(?<=^|' . $spaces . ')--(?=$|' . $spaces . ')/' ] = $em_dash;
$dynamic[ '/(?<!xn)--/' ] = $en_dash;
$dynamic[ '/(?<=' . $spaces . ')-(?=' . $spaces . ')/' ] = $en_dash;
$dynamic[ '/(?<=^|' . $spaces . ')-(?=$|' . $spaces . ')/' ] = $en_dash;
$dynamic_characters['dash'] = array_keys( $dynamic );
$dynamic_replacements['dash'] = array_values( $dynamic );

View File

@ -208,6 +208,19 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
$this->assertEquals( "$nbsp&#8212; ", wptexturize( "$nbsp-- ") );
}
/**
* @ticket 31030
*/
function test_hyphens_at_start_and_end() {
$this->assertEquals( '&#8211; ', wptexturize( '- ' ) );
$this->assertEquals( '&#8211; &#8211;', wptexturize( '- -' ) );
$this->assertEquals( ' &#8211;', wptexturize( ' -' ) );
$this->assertEquals( '&#8212; ', wptexturize( '-- ' ) );
$this->assertEquals( '&#8212; &#8212;', wptexturize( '-- --' ) );
$this->assertEquals( ' &#8212;', wptexturize( ' --' ) );
}
/**
* Test spaces around quotes.
*