Make WordPress Core

Ticket #31030: 31030.diff

File 31030.diff, 1.6 KB (added by pento, 9 years ago)
  • src/wp-includes/formatting.php

     
    174174
    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 );
    182182                $dynamic_replacements['dash'] = array_values( $dynamic );
  • tests/phpunit/tests/formatting/WPTexturize.php

     
    209209        }
    210210
    211211        /**
     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( ' --' ) );
     222        }
     223
     224        /**
    212225         * Test spaces around quotes.
    213226         *
    214227         * These should never happen, even if the desired output changes some day.