Make WordPress Core

Ticket #28718: miqro-28718.patch

File miqro-28718.patch, 7.5 KB (added by miqrogroove, 12 years ago)
  • src/wp-includes/formatting.php

     
    104104
    105105                // '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation.
    106106                if ( "'" !== $apos || "'" !== $closing_single_quote ) {
    107                         $dynamic[ '/\'(\d\d)\'(?=\Z|[.,)}>\-\]]|' . $spaces . ')/' ] = $apos . '$1' . $closing_single_quote;
     107                        $dynamic[ '/\'(\d\d)\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $apos . '$1' . $closing_single_quote;
    108108                }
    109 
    110109                if ( "'" !== $apos || '"' !== $closing_quote ) {
    111                         $dynamic[ '/\'(\d\d)"(?=\Z|[.,)}>\-\]]|' . $spaces . ')/' ] = $apos . '$1' . $closing_quote;
     110                        $dynamic[ '/\'(\d\d)"(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $apos . '$1' . $closing_quote;
    112111                }
    113112
    114113                // '99 '99s '99's (apostrophe)  But never '9 or '99% or '999 or '99.0.
     
    126125
    127126                // Single quote at start, or preceded by (, {, <, [, ", -, or spaces.
    128127                if ( "'" !== $opening_single_quote ) {
    129                         $dynamic[ '/(?<=\A|[([{<"\-]|' . $spaces . ')\'/' ] = $opening_single_quote;
     128                        $dynamic[ '/(?<=\A|[([{"\-]|&lt;|' . $spaces . ')\'/' ] = $opening_single_quote;
    130129                }
    131130
    132131                // Apostrophe in a word.  No spaces, double apostrophes, or other punctuation.
    133132                if ( "'" !== $apos ) {
    134                         $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){}<>[\]\-]|' . $spaces . ')/' ] = $apos;
     133                        $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos;
    135134                }
    136135
    137136                // 9" (double prime)
     
    146145
    147146                // Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces.
    148147                if ( '"' !== $opening_quote ) {
    149                         $dynamic[ '/(?<=\A|[([{<\-]|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote;
     148                        $dynamic[ '/(?<=\A|[([{\-]|&lt;|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote;
    150149                }
    151150
    152151                // Any remaining double quotes.
     
    156155
    157156                // Single quotes followed by spaces or ending punctuation.
    158157                if ( "'" !== $closing_single_quote ) {
    159                         $dynamic[ '/\'(?=\Z|[.,)}>\-\]]|' . $spaces . ')/' ] = $closing_single_quote;
     158                        $dynamic[ '/\'(?=\Z|[.,)}\-\]]|&gt;|' . $spaces . ')/' ] = $closing_single_quote;
    160159                }
    161160
    162161                // Dashes and spaces
  • tests/phpunit/tests/formatting/WPTexturize.php

     
    117117                $this->assertEquals('&#8216;Class of &#8217;99&#8217;s&#8217;', wptexturize("'Class of '99&#8217;s'"));
    118118                //$this->assertEquals('&#8220;Class of 99&#8221;', wptexturize("\"Class of 99\""));
    119119                $this->assertEquals('&#8220;Class of &#8217;99&#8221;', wptexturize("\"Class of '99\""));
     120                $this->assertEquals('{&#8220;Class of &#8217;99&#8221;}', wptexturize("{\"Class of '99\"}"));
     121                $this->assertEquals(' &#8220;Class of &#8217;99&#8221; ', wptexturize(" \"Class of '99\" "));
     122                $this->assertEquals('}&#8220;Class of &#8217;99&#8221;{', wptexturize("}\"Class of '99\"{")); // Not a quotation, may be between two other quotations.
    120123        }
    121124
    122125        function test_quotes_after_numbers() {
     
    346349                                "word [&#8216;word word",
    347350                        ),
    348351                        array(
    349                                 "word <'word word", // Invalid HTML input?
    350                                 "word <&#8216;word word",
     352                                "word <'word word", // Invalid HTML input triggers the apos in a word pattern.
     353                                "word <&#8217;word word",
    351354                        ),
    352355                        array(
    353                                 "word &lt;'word word", // Valid HTML input triggers the apos in a word pattern
    354                                 "word &lt;&#8217;word word",
     356                                "word &lt;'word word", // Valid HTML input makes curly quotes.
     357                                "word &lt;&#8216;word word",
    355358                        ),
    356359                        array(
    357360                                "word {'word word",
     
    375378                        ),
    376379                        array(
    377380                                "word<'word word",
    378                                 "word<&#8216;word word",
     381                                "word<&#8217;word word",
    379382                        ),
    380383                        array(
    381384                                "word&lt;'word word",
    382                                 "word&lt;&#8217;word word",
     385                                "word&lt;&#8216;word word",
    383386                        ),
    384387                        array(
    385388                                "word{'word word",
     
    402405                                "word [&#8216; word word",
    403406                        ),
    404407                        array(
    405                                 "word <' word word", // Invalid HTML input?
    406                                 "word <&#8216; word word",
     408                                "word <' word word",
     409                                "word <&#8217; word word",
    407410                        ),
    408411                        array(
    409                                 "word &lt;' word word", // Valid HTML input triggers the closing single quote here
    410                                 "word &lt;&#8217; word word",
     412                                "word &lt;' word word",
     413                                "word &lt;&#8216; word word",
    411414                        ),
    412415                        array(
    413416                                "word {' word word",
     
    431434                        ),
    432435                        array(
    433436                                "word<' word word",
    434                                 "word<&#8216; word word",
     437                                "word<&#8217; word word",
    435438                        ),
    436439                        array(
    437440                                "word&lt;' word word",
    438                                 "word&lt;&#8217; word word",
     441                                "word&lt;&#8216; word word",
    439442                        ),
    440443                        array(
    441444                                "word{' word word",
     
    533536                                "word word&#8217;s word",
    534537                        ),
    535538                        array(
    536                                 "word word'. word", // Quotes with outside punctuation could end with apostrophes instead of closing quotes (may affect i18n)
    537                                 "word word&#8217;. word",
     539                                "word'[ word", // Apostrophes are never followed by opening punctuation.
     540                                "word'[ word",
    538541                        ),
    539542                        array(
    540                                 "word ]'. word",
    541                                 "word ]&#8217;. word",
     543                                "word'( word",
     544                                "word'( word",
    542545                        ),
    543546                        array(
    544                                 "word )'. word",
    545                                 "word )&#8217;. word",
     547                                "word'{ word",
     548                                "word'{ word",
    546549                        ),
    547550                        array(
    548                                 "word }'. word",
    549                                 "word }&#8217;. word",
     551                                "word'&lt; word",
     552                                "word'&lt; word",
    550553                        ),
    551554                        array(
    552                                 "word >'. word", // Not tested
    553                                 "word >&#8217;. word",
     555                                "word'< word", // Invalid HTML input does trigger the apos pattern.
     556                                "word&#8217;< word",
    554557                        ),
    555                         array(
    556                                 "word &gt;'. word",
    557                                 "word &gt;&#8217;. word",
    558                         ),
    559558                );
    560559        }
    561560
    562561        /**
    563          * Double quote after a space or ([{< becomes &#8220; (opening_quote) if not followed by spaces
     562         * Double quote after a space or ([-{< becomes &#8220; (opening_quote) if not followed by spaces
    564563         *
    565564         * Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail.
    566565         *
     
    586585                                'word [&#8220;word word',
    587586                        ),
    588587                        array(
    589                                 'word <"word word', // Invalid HTML input?
    590                                 'word <&#8220;word word',
     588                                'word <"word word', // Invalid HTML input triggers the closing quote pattern.
     589                                'word <&#8221;word word',
    591590                        ),
    592591                        array(
    593                                 'word &lt;"word word', // Valid HTML input triggers the closing quote pattern
    594                                 'word &lt;&#8221;word word',
     592                                'word &lt;"word word',
     593                                'word &lt;&#8220;word word',
    595594                        ),
    596595                        array(
    597596                                'word {"word word',
     
    598597                                'word {&#8220;word word',
    599598                        ),
    600599                        array(
     600                                'word -"word word',
     601                                'word -&#8220;word word',
     602                        ),
     603                        array(
     604                                'word-"word word',
     605                                'word-&#8220;word word',
     606                        ),
     607                        array(
    601608                                '"word word',
    602609                                '&#8220;word word',
    603610                        ),
     
    698705        }
    699706
    700707        /**
    701          * Test that single quotes followed by a space or a period become &#8217; (closing_single_quote)
     708         * Test that single quotes followed by a space or .,-)}]> become &#8217; (closing_single_quote)
    702709         *
    703710         * Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail.
    704711         *
     
    728735                                "word word&#8217;, she said",
    729736                        ),
    730737                        array(
     738                                "word word'- word",
     739                                "word word&#8217;- word",
     740                        ),
     741                        array(
     742                                "word word') word",
     743                                "word word&#8217;) word",
     744                        ),
     745                        array(
     746                                "word word'} word",
     747                                "word word&#8217;} word",
     748                        ),
     749                        array(
     750                                "word word'] word",
     751                                "word word&#8217;] word",
     752                        ),
     753                        array(
     754                                "word word'&gt; word",
     755                                "word word&#8217;&gt; word",
     756                        ),
     757                        array(
    731758                                "word word'",
    732759                                "word word&#8217;",
    733760                        ),