WordPress.org

Make WordPress Core

Ticket #4539: dev-snapshot-2010-12-11.php.diff

File dev-snapshot-2010-12-11.php.diff, 22.4 KB (added by norbertm, 3 years ago)
  • wordpress/wp-includes/formatting.php

     
    3131        static $static_setup = false, $opening_quote, $closing_quote, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements; 
    3232        $output = ''; 
    3333        $curl = ''; 
    34         $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); 
     34        $textarr = preg_split('/(<!--.*-->|<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); 
    3535        $stop = count($textarr); 
    3636 
    3737        // No need to set up these variables more than once 
     
    5656                $static_characters = array_merge(array('---', ' -- ', '--', ' - ', 'xn&#8211;', '...', '``', '\'\'', ' (tm)'), $cockney); 
    5757                $static_replacements = array_merge(array('&#8212;', ' &#8212; ', '&#8211;', ' &#8211; ', 'xn--', '&#8230;', $opening_quote, $closing_quote, ' &#8482;'), $cockneyreplace); 
    5858 
    59                 $dynamic_characters = array('/\'(\d\d(?:&#8217;|\')?s)/', '/\'(\d)/', '/(\s|\A|[([{<]|")\'/', '/(\d)"/', '/(\d)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A|[([{<])"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/\b(\d+)x(\d+)\b/'); 
    60                 $dynamic_replacements = array('&#8217;$1','&#8217;$1', '$1&#8216;', '$1&#8243;', '$1&#8242;', '$1&#8217;$2', '$1' . $opening_quote . '$2', $closing_quote . '$1', '&#8217;$1', '$1&#215;$2'); 
     59                $dynamic_map = array( 
     60                        '/(^|\s)\'([^\'\s]+)([^\']*)\'(\d+)\'(\s|$)/' => '$1\'$2$3&#8217;$4\'$5', // 'Class of '99' 
     61                        '/(^|\s)\'(\d+)([^\d\'(?:x\d+)]|\'\w|[\]})]|$)/' => '$1&#8217;$2$3', // '99, '99's (?: part meaning not '99x11 - see below) 
     62                        '/([\w\]})])\'([\w])/' => '$1&#8217;$2', // test's 
     63                        '/\'([^\']*)\'/' => '&#8216;$1&#8217;', // 'asd' 
     64                        '/"([^"]*)"/' => $opening_quote . '$1' . $closing_quote, // "qwe" 
     65                        '/(^|\s)(\d)\'/' => '$1$2&#8242;', // 9' 
     66                        '/(^|\s)(\d)"/' => '$1$2&#8243;', // 9" 
     67                        '/\b(\d+)x(\d+)\b/' => '$1&#215;$2' // 97x34 
     68                ); 
    6169 
     70                $dynamic_characters = array_keys( $dynamic_map ); 
     71                $dynamic_replacements = array_values( $dynamic_map ); 
     72 
    6273                $static_setup = true; 
    6374        } 
    6475 
     
    7081        $no_texturize_tags_stack = array(); 
    7182        $no_texturize_shortcodes_stack = array(); 
    7283 
     84        $single_quote_state = '&#8216;'; 
     85        $double_quote_state = $opening_quote; 
     86 
     87        $text_node_count = 0; 
     88        $whitespace_before_last_tag = false; 
     89 
    7390        for ( $i = 0; $i < $stop; $i++ ) { 
    7491                $curl = $textarr[$i]; 
    7592 
     
    7895                        // This is not a tag, nor is the texturization disabled 
    7996                        // static strings 
    8097                        $curl = str_replace($static_characters, $static_replacements, $curl); 
     98                        // quotes after tags, e.g. <b>somebody</b>'s 
     99                        if ( ( $text_node_count > 0 ) && ( ! $whitespace_before_last_tag ) ) { 
     100                                $curl = preg_replace( '/^(\')/', '&#8217;', $curl ); 
     101                        } 
     102 
    81103                        // regular expressions 
    82104                        $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); 
     105 
     106                        // Quotes that span across multiple tags & shortcodes 
     107                        // Dynamic regexps above ensure that there is at most 1 quote left in the string. 
     108                        // Otherwise, the less efficient preg_replace() within a while loop would be required. 
     109                        if ( strpos( $curl, '\'' ) !== false ) { 
     110                                $curl = str_replace( '\'', $single_quote_state, $curl); 
     111                                $single_quote_state = ( ( '&#8216;' == $single_quote_state ) ? '&#8217;' : '&#8216;' ); 
     112                        } 
     113                        if ( strpos($curl, '"' ) !== false ) { 
     114                                $curl = str_replace( '"', $double_quote_state, $curl); 
     115                                $double_quote_state = ( $opening_quote == $double_quote_state ) ? $closing_quote : $opening_quote; 
     116                        } 
     117                        // stats for quotes after tags above 
     118                        $text_node_count++; 
     119                        $whitespace_before_last_tag = ( preg_match('/\s$/', $curl) > 0 ); 
    83120                } elseif (!empty($curl)) { 
    84121                        /* 
    85122                         * Only call _wptexturize_pushpop_element if first char is correct 
  • wp-testcase/test_includes_formatting.php

     
    352352        function test_dashes() { 
    353353                $this->assertEquals('Hey &#8212; boo?', wptexturize('Hey -- boo?')); 
    354354                $this->assertEquals('<a href="http://xx--xx">Hey &#8212; boo?</a>', wptexturize('<a href="http://xx--xx">Hey -- boo?</a>')); 
     355                $this->assertEquals('Hey&#8212;boo?', wptexturize('Hey---boo?')); 
     356                $this->assertEquals('<a href="http://xx---xx">Hey&#8212;boo?</a>', wptexturize('<a href="http://xx---xx">Hey---boo?</a>')); 
    355357        } 
    356358         
    357359        function test_disable() { 
     
    371373                 
    372374                $invalid_nest = '<pre></code>"baba"</pre>'; 
    373375                $this->assertEquals($invalid_nest, wptexturize($invalid_nest)); 
     376        } 
    374377 
     378        //WP Ticket #8912, #10033 
     379        function test_skip_html_comments() { 
     380                $this->assertEquals('<ul><li>Hello.</li><!--<li>Goodbye.</li>--></ul>', wptexturize('<ul><li>Hello.</li><!--<li>Goodbye.</li>--></ul>')); 
     381 
     382                $html = '<!--[if !IE]>-->' . "\n"; 
     383                $html .= '<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/_nkZ3eHeXlc" width="320" height="260">' . "\n"; 
     384                $html .= '<!--<![endif]-->' . "\n"; 
     385                $this->assertEquals($html, wptexturize($html)); 
     386 
     387                $html = '<!--[if !IE]>-->' . "\n"; 
     388                $html .= '</object>' . "\n"; 
     389                $html .= '<!--<![endif]-->' . "\n"; 
     390                $this->assertEquals($html, wptexturize($html)); 
    375391        } 
    376392         
    377393        //WP Ticket #1418 
     
    388404         
    389405        //WP Ticket #4539 
    390406        function test_basic_quotes() { 
     407                $this->assertNotEquals('&#8216;&#8217;', wptexturize("''")); // this does not work as expected due to a static replacement 
     408                $this->assertEquals('&#8220;&#8221;', wptexturize('""')); 
     409                $this->assertEquals('&#8220;&#8221;', wptexturize("``''")); // this is what causes '' to fail 
     410                $this->assertEquals('&#8216; &#8217;', wptexturize("' '")); 
     411                $this->assertEquals('&#8220; &#8221;', wptexturize('" "')); 
     412                $this->assertEquals('&#8216;<img src="">&#8217;', wptexturize('\'<img src="">\'')); 
     413                $this->assertEquals('&#8220;<img src="">&#8221;', wptexturize('"<img src="">"')); 
     414                $this->assertEquals('Peter&#8217;s photo: &#8216;<img src="">&#8217;', wptexturize('Peter\'s photo: \'<img src="">\'')); 
     415                $this->assertEquals('Peter&#8217;s photo: &#8220;<img src="">&#8221;', wptexturize('Peter\'s photo: "<img src="">"')); 
     416 
    391417                $this->assertEquals('test&#8217;s', wptexturize('test\'s')); 
    392418                $this->assertEquals('test&#8217;s', wptexturize('test\'s')); 
    393419 
    394420                $this->assertEquals('&#8216;quoted&#8217;', wptexturize('\'quoted\'')); 
    395421                $this->assertEquals('&#8220;quoted&#8221;', wptexturize('"quoted"')); 
     422                $this->assertEquals('&#8216;quoted&#8217;s&#8217;', wptexturize('\'quoted\'s\'')); 
     423                $this->assertEquals('&#8220;quoted&#8217;s&#8221;', wptexturize('"quoted\'s"')); 
    396424 
    397425                $this->assertEquals('(&#8216;quoted&#8217;)', wptexturize('(\'quoted\')')); 
    398426                $this->assertEquals('{&#8220;quoted&#8221;}', wptexturize('{"quoted"}')); 
     427                $this->assertEquals('["quoted"]', wptexturize('["quoted"]')); // shortcode 
     428                $this->assertEquals('<"quoted">', wptexturize('<"quoted">')); // tag 
     429                $this->assertEquals('(&#8216;quoted&#8217;s&#8217;)', wptexturize('(\'quoted\'s\')')); 
     430                $this->assertEquals('{&#8220;quoted&#8217;s&#8221;}', wptexturize('{"quoted\'s"}')); 
     431                $this->assertEquals('["quoted\'s"]', wptexturize('["quoted\'s"]')); // shortcode 
     432                $this->assertEquals('<"quoted\'s">', wptexturize('<"quoted\'s">')); // tag 
    399433 
    400434                $this->assertEquals('&#8216;qu(ot)ed&#8217;', wptexturize('\'qu(ot)ed\'')); 
    401435                $this->assertEquals('&#8220;qu{ot}ed&#8221;', wptexturize('"qu{ot}ed"')); 
     436                $this->assertEquals('&#8220;qu[ot]ed&#8221;', wptexturize('"qu[ot]ed"')); 
     437                $this->assertEquals('&#8220;qu<ot>ed&#8221;', wptexturize('"qu<ot>ed"')); 
     438                $this->assertEquals('&#8216;qu(ot)ed&#8217;s&#8217;', wptexturize('\'qu(ot)ed\'s\'')); 
     439                $this->assertEquals('&#8220;qu{ot}ed&#8217;s&#8221;', wptexturize('"qu{ot}ed\'s"')); 
     440                $this->assertEquals('&#8220;qu[ot]ed&#8217;s&#8221;', wptexturize('"qu[ot]ed\'s"')); 
     441                $this->assertEquals('&#8220;qu<ot>ed&#8217;s&#8221;', wptexturize('"qu<ot>ed\'s"')); 
     442                $this->assertEquals('&#8216;qu(ot)&#8217;s&#8217;', wptexturize('\'qu(ot)\'s\'')); 
     443                $this->assertEquals('&#8220;qu{ot}&#8217;s&#8221;', wptexturize('"qu{ot}\'s"')); 
     444                $this->assertEquals('&#8220;qu[ot]&#8217;s&#8221;', wptexturize('"qu[ot]\'s"')); 
     445                $this->assertEquals('&#8220;qu<ot>&#8217;s&#8221;', wptexturize('"qu<ot>\'s"')); 
    402446 
    403447                $this->assertEquals('&#8216;test&#8217;s quoted&#8217;', wptexturize('\'test\'s quoted\'')); 
    404448                $this->assertEquals('&#8220;test&#8217;s quoted&#8221;', wptexturize('"test\'s quoted"')); 
    405449        } 
     450         
     451        //WP Ticket #4539 
     452        function test_original_report_4539() { 
     453                $this->assertEquals("(Bruce Sterling, &#8217;97)", wptexturize("(Bruce Sterling, '97)")); 
     454                $this->assertEquals("( Bruce Sterling, &#8217;97 )", wptexturize("( Bruce Sterling, '97 )")); 
     455                $this->assertEquals("<li>Casino Royale &#8217;06</li>", wptexturize("<li>Casino Royale '06</li>")); 
     456                $this->assertEquals("<li>(Casino Royale &#8217;06)</li>", wptexturize("<li>(Casino Royale '06)</li>")); 
     457        } 
    406458 
     459        //WP Ticket #14491 
     460        function test_quoted_numbers() { 
     461                $this->knownWPBug(14491); 
     462 
     463                // 4 digits 
     464                $this->assertEquals('&#8216;2010&#8217;', wptexturize("'2010'")); 
     465                $this->assertEquals('&#8220;2011&#8221;', wptexturize('"2011"')); 
     466                $this->assertEquals('&#8216; 2010 &#8217;', wptexturize("' 2010 '")); 
     467                $this->assertEquals('&#8220; 2011 &#8221;', wptexturize('" 2011 "')); 
     468                $this->assertEquals(' &#8216;2010&#8217; ', wptexturize(" '2010' ")); 
     469                $this->assertEquals(' &#8220;2011&#8221; ', wptexturize(' "2011" ')); 
     470                $this->assertEquals(' &#8216; 2010 &#8217; ', wptexturize(" ' 2010 ' ")); 
     471                $this->assertEquals(' &#8220; 2011 &#8221; ', wptexturize(' " 2011 " ')); 
     472 
     473                // 2 digits to test against '99' vs '99'ers 
     474                $this->assertEquals('&#8216;10&#8217;', wptexturize("'10'")); 
     475                $this->assertEquals('&#8220;11&#8221;', wptexturize('"11"')); 
     476                $this->assertEquals('&#8216; 10 &#8217;', wptexturize("' 10 '")); 
     477                $this->assertEquals('&#8220; 11 &#8221;', wptexturize('" 11 "')); 
     478                $this->assertEquals(' &#8216;10&#8217; ', wptexturize(" '10' ")); 
     479                $this->assertEquals(' &#8220;11&#8221; ', wptexturize(' "11" ')); 
     480                $this->assertEquals(' &#8216; 10 &#8217; ', wptexturize(" ' 10 ' ")); 
     481                $this->assertEquals(' &#8220; 11 &#8221; ', wptexturize(' " 11 " ')); 
     482        } 
     483 
     484        //WP Ticket #4539 
     485        function test_nested_quotes() { 
     486                $this->assertEquals('&#8220;This is a &#8216;nested quote&#8217;.&#8221;', wptexturize('"This is a \'nested quote\'."')); 
     487                $this->assertEquals('&#8216;This is a &#8220;nested quote&#8221;.&#8217;', wptexturize('\'This is a "nested quote".\'')); 
     488                $this->assertEquals('&#8220;These are some &#8216;nested&#8217; &#8216;quotes&#8217;.&#8221;', wptexturize('"These are some \'nested\' \'quotes\'."')); 
     489                $this->assertEquals('&#8216;These are some &#8220;nested&#8221; &#8220;quotes&#8221;.&#8217;', wptexturize('\'These are some "nested" "quotes".\'')); 
     490        } 
     491 
    407492        //WP Tickets #4539, #15241 
    408493        function test_full_sentences_with_unmatched_single_quotes() { 
    409494                $this->assertEquals( 
    410495                        'That means every moment you&#8217;re working on something without it being in the public it&#8217;s actually dying.', 
    411496                        wptexturize("That means every moment you're working on something without it being in the public it's actually dying.") 
    412497                ); 
     498                $this->assertEquals( 
     499                        '&#8216;That means every moment you&#8217;re working on something without it being in the public it&#8217;s actually dying.&#8217;', 
     500                        wptexturize("'That means every moment you're working on something without it being in the public it's actually dying.'") 
     501                ); 
     502                $this->assertEquals( 
     503                        '&#8220;That means every moment you&#8217;re working on something without it being in the public it&#8217;s actually dying.&#8221;', 
     504                        wptexturize("\"That means every moment you're working on something without it being in the public it's actually dying.\"") 
     505                ); 
     506                $this->assertEquals( 
     507                        'That means every moment you&#8217;re working on &#8216;something&#8217; without it being in the public it&#8217;s actually dying.', 
     508                        wptexturize("That means every moment you're working on 'something' without it being in the public it's actually dying.") 
     509                ); 
     510                $this->assertEquals( 
     511                        'That means every moment you&#8217;re working on &#8220;something&#8221; without it being in the public it&#8217;s actually dying.', 
     512                        wptexturize("That means every moment you're working on \"something\" without it being in the public it's actually dying.") 
     513                ); 
    413514        } 
    414515 
    415         //WP Ticket #4539 
     516        //WP Tickets #4539, #10606 
    416517        function test_quotes() { 
    417518                $this->knownWPBug(4539); 
     519 
     520                $this->assertEquals('text &#8220;[link]&#8221;.', wptexturize('text "[link]".')); 
     521                $this->assertEquals('text &#8220;[link]&#8221;, text.', wptexturize('text "[link]", text.')); 
     522                $this->assertEquals('text &#8220;[link]&#8221;; text.', wptexturize('text "[link]"; text.')); 
     523                $this->assertEquals('text &#8220;[link]&#8221;- text.', wptexturize('text "[link]"- text.')); 
     524                $this->assertEquals('text &#8220;text [link]&#8221;.', wptexturize('text "text [link]".')); 
     525                $this->assertEquals('text &#8220;text [link]&#8221;&#8230;', wptexturize('text "text [link]"...')); 
     526                $this->assertEquals('text &#8220;text [link]&#8221;text.', wptexturize('text "text [link]"text.')); 
     527 
     528                $this->assertEquals('text &#8220;text 14&#8221;.', wptexturize('text "text 14".')); 
     529                $this->assertEquals('text &#8220;text 14&#8221; text.', wptexturize('text "text 14" text.')); 
     530 
    418531                $this->assertEquals('&#8220;Quoted String&#8221;', wptexturize('"Quoted String"')); 
    419532                $this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"')); 
     533                $this->assertEquals('Here is &#8220; <a href="http://example.com">a test with a link</a> &#8221;', wptexturize('Here is " <a href="http://example.com">a test with a link</a> "')); 
     534                $this->assertEquals('Here is &#8220;<a href="http://example.com"> a test with a link </a>&#8221;', wptexturize('Here is "<a href="http://example.com"> a test with a link </a>"')); 
    420535                $this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link and a period</a>&#8221;.', wptexturize('Here is "<a href="http://example.com">a test with a link and a period</a>".')); 
    421536                $this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221; and a space.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>" and a space.')); 
    422537                $this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a> and some text quoted&#8221;', wptexturize('Here is "<a href="http://example.com">a test with a link</a> and some text quoted"')); 
     
    424539                $this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;; and a semi-colon.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"; and a semi-colon.')); 
    425540                $this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;- and a dash.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"- and a dash.')); 
    426541                $this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;&#8230; and ellipses.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"... and ellipses.')); 
     542                $this->assertEquals('Here is &#8220;<a href="http://example.com">a test</a> with a link&#8221;.', wptexturize('Here is "<a href="http://example.com">a test</a> with a link".')); 
    427543                $this->assertEquals('Here is &#8220;a test <a href="http://example.com">with a link</a>&#8221;.', wptexturize('Here is "a test <a href="http://example.com">with a link</a>".')); 
    428                 $this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;and a work stuck to the end.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"and a work stuck to the end.')); 
     544                $this->assertEquals('Here is &#8220;a test <a href="http://example.com">with a link</a>&#8221; .', wptexturize('Here is "a test <a href="http://example.com">with a link</a>" .')); 
     545                $this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;and a word stuck to the end.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"and a word stuck to the end.')); 
    429546                $this->assertEquals('A test with a finishing number, &#8220;like 23&#8221;.', wptexturize('A test with a finishing number, "like 23".')); 
    430547                $this->assertEquals('A test with a number, &#8220;like 62&#8221;, is nice to have.', wptexturize('A test with a number, "like 62", is nice to have.')); 
    431548        } 
     
    443560        //WP Ticket #4539 
    444561        function test_quotes_before_numbers() { 
    445562                $this->knownWPBug(4539); 
     563                $this->assertEquals('&#8217;99', wptexturize("'99")); 
     564 
     565                $this->assertEquals('&#8217;99&#8217;s', wptexturize("'99&#8217;s")); 
     566                $this->assertEquals('&#8217;99&#8217;ers', wptexturize("'99&#8217;ers")); 
     567                $this->assertEquals('&#8217;749&#8217;ers', wptexturize("'749&#8217;ers")); 
     568 
     569                $this->assertEquals('&#8217;99&#8217;s', wptexturize("'99's")); 
     570                $this->assertEquals('&#8217;99&#8217;ers', wptexturize("'99'ers")); 
     571                $this->assertEquals('&#8217;749&#8217;ers', wptexturize("'749'ers")); 
     572 
    446573                $this->assertEquals('Class of &#8217;99', wptexturize("Class of '99")); 
    447574                $this->assertEquals('Class of &#8217;99&#8217;s', wptexturize("Class of '99's")); 
     575                 
    448576                $this->assertEquals('&#8216;Class of &#8217;99&#8217;', wptexturize("'Class of '99'")); 
     577                $this->assertEquals(' &#8216;Class of &#8217;99&#8217; ', wptexturize(" 'Class of '99' ")); 
     578                $this->assertEquals('&#8216; Class of &#8217;99 &#8217;', wptexturize("' Class of '99 '")); 
     579                $this->assertEquals(' &#8216; Class of &#8217;99 &#8217; ', wptexturize(" ' Class of '99 ' ")); 
     580                 
    449581                $this->assertEquals('&#8216;Class of &#8217;99&#8217;s&#8217;', wptexturize("'Class of '99's'")); 
    450582                $this->assertEquals('&#8216;Class of &#8217;99&#8217;s&#8217;', wptexturize("'Class of '99&#8217;s'")); 
     583 
    451584                $this->assertEquals('&#8220;Class of 99&#8221;', wptexturize("\"Class of 99\"")); 
    452585                $this->assertEquals('&#8220;Class of &#8217;99&#8221;', wptexturize("\"Class of '99\"")); 
     586                $this->assertEquals('&#8220;Class of &#8217;99&#8217;s&#8221;', wptexturize("\"Class of '99's\"")); 
    453587        } 
    454          
    455         function test_quotes_after_numbers() { 
    456                 $this->assertEquals('Class of &#8217;99', wptexturize("Class of '99")); 
    457         } 
    458          
     588 
    459589        //WP Ticket #15241 
    460590        function test_other_html() { 
    461591                $this->knownWPBug(15241); 
    462592                $this->assertEquals('&#8216;<strong>', wptexturize("'<strong>")); 
     593                $this->assertEquals('&#8220;<strong>', wptexturize('"<strong>')); 
     594                $this->assertEquals('&#8216;<strong></strong>&#8217;', wptexturize("'<strong></strong>'")); 
     595                $this->assertEquals('&#8220;<strong></strong>&#8221;', wptexturize('"<strong></strong>"')); 
    463596                $this->assertEquals('&#8216;<strong>Quoted Text</strong>&#8217;,', wptexturize("'<strong>Quoted Text</strong>',")); 
    464597                $this->assertEquals('&#8220;<strong>Quoted Text</strong>&#8221;,', wptexturize('"<strong>Quoted Text</strong>",')); 
    465598        } 
    466          
     599 
     600        //WP Ticket #15241 
     601        function test_many_single_quotes() { 
     602                $this->assertEquals('This isn&#8217;t inherently bad, but I don&#8217;t think it&#8217;s normal.', wptexturize("This isn't inherently bad, but I don't think it's normal.")); 
     603        } 
     604 
     605        //WP Ticket #1258 
     606        function test_enumeration() { 
     607                $this->assertEquals("&#8216;products&#8217;, &#8216;services&#8217;", wptexturize("'products', 'services'")); 
     608                $this->assertEquals("&#8216;hello&#8217;, &#8216;world&#8217;, &#8217;tis", wptexturize("'hello', 'world', 'tis")); 
     609                $this->assertEquals("&#8216;hello&#8217;, &#8216;world&#8217;, &#8217;tis ", wptexturize("'hello', 'world', 'tis ")); 
     610        } 
     611 
     612        //WP Ticket #11275 
     613        function test_quoting() { 
     614                $this->assertEquals('She said—&#8220;No!&#8221;', wptexturize('She said—"No!"')); 
     615                $this->assertEquals('She said — &#8220;No!&#8221;', wptexturize('She said — "No!"')); 
     616                $this->assertEquals('She said—&#8220;<a href="#">No!</a>&#8221;', wptexturize('She said—"<a href="#">No!</a>"')); 
     617                $this->assertEquals('She said—&#8216;<a href="#">It&#8217;s Peter&#8217;s!</a>&#8217;', wptexturize('She said—\'<a href="#">It\'s Peter\'s!</a>\'')); 
     618                $this->assertEquals('She said—&#8220;<a href="#">It&#8217;s Peter&#8217;s!</a>&#8221;', wptexturize('She said—"<a href="#">It\'s Peter\'s!</a>"')); 
     619        } 
     620 
     621        //WP Ticket #15444 
     622        function test_tag_followed_by_quote() { 
     623                $this->knownWPBug(15444); 
     624                $this->assertEquals('<a href="#">Jim</a>&#8217;s red bike.', wptexturize('<a href="#">Jim</a>\'s red bike.')); 
     625                $this->assertEquals('&#8216;<a href="#">Jim</a>&#8217;s red bike.&#8217;', wptexturize('\'<a href="#">Jim</a>\'s red bike.\'')); 
     626                $this->assertEquals('&#8220;<a href="#">Jim</a>&#8217;s red bike.&#8221;', wptexturize('"<a href="#">Jim</a>\'s red bike."')); 
     627                $this->assertEquals('<a href="#">Jim</a>&#8217;s &#8216;red bike.&#8217;', wptexturize('<a href="#">Jim</a>\'s \'red bike.\'')); 
     628                $this->assertEquals('<a href="#">Jim</a>&#8217;s &#8220;red bike.&#8221;', wptexturize('<a href="#">Jim</a>\'s "red bike."')); 
     629                $this->assertEquals('<a href="#">Jim</a>&#8217;s &#8216;<a href="#">red bike</a>.&#8217;', wptexturize('<a href="#">Jim</a>\'s \'<a href="#">red bike</a>.\'')); 
     630                $this->assertEquals('<a href="#">Jim</a>&#8217;s &#8220;<a href="#">red bike</a>.&#8221;', wptexturize('<a href="#">Jim</a>\'s "<a href="#">red bike</a>."')); 
     631        } 
     632 
    467633        function test_x() { 
    468634                $this->assertEquals('14&#215;24', wptexturize("14x24")); 
     635                $this->assertEquals(' 14&#215;24', wptexturize(" 14x24")); 
     636                $this->assertEquals('&#8216;14&#215;24&#8217;', wptexturize("'14x24'")); 
     637                $this->assertEquals('&#8220;14&#215;24&#8221;', wptexturize('"14x24"')); 
     638                $this->assertEquals('&#8216;<a href="#">14&#215;24</a>&#8217;', wptexturize('\'<a href="#">14x24</a>\'')); 
     639                $this->assertEquals('&#8220;<a href="#">14&#215;24</a>&#8221;', wptexturize('"<a href="#">14x24</a>"')); 
    469640        } 
    470          
     641 
     642        //WP Ticket #4116 
     643        function test_x_4116() { 
     644                $this->knownWPBug(4116); 
     645                $this->assertEquals('www.a4x3b.com', wptexturize("www.a4x3b.com")); 
     646                $this->assertEquals('http://www.youtube.com/watch?v=irWR7F0x2uU', wptexturize("http://www.youtube.com/watch?v=irWR7F0x2uU")); 
     647        } 
     648 
    471649        function test_minutes_seconds() { 
    472650                $this->assertEquals('9&#8242;', wptexturize('9\'')); 
    473651                $this->assertEquals('9&#8243;', wptexturize("9\"")); 
     
    484662                $this->assertEquals('&nbsp;&#8220;Testing&#8221;', wptexturize('&nbsp;"Testing"')); 
    485663                $this->assertEquals('&#38;&#8220;Testing&#8221;', wptexturize('&#38;"Testing"')); 
    486664        } 
     665 
     666        //WP Ticket #6969 
     667        function test_shortcode_skip() { 
     668                $this->assertEquals('[code lang="php"]$foo = \'bar\';[/code]', wptexturize('[code lang="php"]$foo = \'bar\';[/code]')); 
     669        } 
     670 
    487671} 
    488672 
    489673class TestCleanUrl extends WPTestCase {