Make WordPress Core

Changeset 31199


Ignore:
Timestamp:
01/16/2015 03:54:00 AM (10 years ago)
Author:
pento
Message:

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

Fixes #31030

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r31186 r31199  
    175175        // Dashes and spaces
    176176        $dynamic[ '/---/' ] = $em_dash;
    177         $dynamic[ '/(?<=' . $spaces . ')--(?=' . $spaces . ')/' ] = $em_dash;
     177        $dynamic[ '/(?<=^|' . $spaces . ')--(?=$|' . $spaces . ')/' ] = $em_dash;
    178178        $dynamic[ '/(?<!xn)--/' ] = $en_dash;
    179         $dynamic[ '/(?<=' . $spaces . ')-(?=' . $spaces . ')/' ] = $en_dash;
     179        $dynamic[ '/(?<=^|' . $spaces . ')-(?=$|' . $spaces . ')/' ] = $en_dash;
    180180
    181181        $dynamic_characters['dash'] = array_keys( $dynamic );
  • trunk/tests/phpunit/tests/formatting/WPTexturize.php

    r30752 r31199  
    207207        $this->assertEquals( " &#8212;$nbsp", wptexturize( " --$nbsp" ) );
    208208        $this->assertEquals( "$nbsp&#8212; ", wptexturize( "$nbsp-- ") );
     209    }
     210
     211    /**
     212     * @ticket 31030
     213     */
     214    function test_hyphens_at_start_and_end() {
     215        $this->assertEquals( '&#8211; ', wptexturize( '- ' ) );
     216        $this->assertEquals( '&#8211; &#8211;', wptexturize( '- -' ) );
     217        $this->assertEquals( ' &#8211;', wptexturize( ' -' ) );
     218
     219        $this->assertEquals( '&#8212; ', wptexturize( '-- ' ) );
     220        $this->assertEquals( '&#8212; &#8212;', wptexturize( '-- --' ) );
     221        $this->assertEquals( ' &#8212;', wptexturize( ' --' ) );
    209222    }
    210223
Note: See TracChangeset for help on using the changeset viewer.