Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/WPTexturize.php

    r30450 r28971  
    1212        function test_disable() {
    1313                $this->assertEquals('<pre>---</pre>', wptexturize('<pre>---</pre>'));
     14                $this->assertEquals('[a]a&#8211;b[code]---[/code]a&#8211;b[/a]', wptexturize('[a]a--b[code]---[/code]a--b[/a]'));
    1415                $this->assertEquals('<pre><code></code>--</pre>', wptexturize('<pre><code></code>--</pre>'));
    1516
     
    11931194                        ),
    11941195                        array(
    1195                                 '[is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]',
    1196                                 '[is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]',
    1197                         ),
    1198                         array(
    1199                                 '[caption - is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]',
    1200                                 '[caption &#8211; is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]',
    1201                         ),
    1202                         array(
    1203                                 '[caption - is it wise to <a title="allow user content here? hmm"> ] maybe </a> ]',
    1204                                 '[caption - is it wise to <a title="allow user content here? hmm"> ] maybe </a> ]',
    1205                         ),
    1206                         array(
    1207                                 '[caption - is it wise to <a title="allow user content here? hmm"> maybe </a> ]',
    1208                                 '[caption - is it wise to <a title="allow user content here? hmm"> maybe </a> ]',
    1209                         ),
    1210                         array(
    1211                                 '[caption compare=">"]',
    1212                                 '[caption compare=&#8221;>&#8221;]',
    1213                         ),
    1214                         array(
    1215                                 '[caption compare="<>"]',
    1216                                 '[caption compare="<>"]',
    1217                         ),
    1218                         array(
    1219                                 '[caption compare="<" attr2="value" <!-->/]',
    1220                                 '[caption compare="<" attr2="value" <!-->/]',
    1221                         ),
    1222                         array(
    1223                                 '[caption compare="<"]',
    1224                                 '[caption compare=&#8221;<&#8221;]',
    1225                         ),
    1226                         array(
    1227                                 '[caption compare="<"]<br />',
    1228                                 '[caption compare=&#8221;<"]<br />',
    1229                         ),
    1230                         array(
    12311196                                '[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy </a> ]',
    12321197                                '[ photos by <a href="http://example.com/?a[]=1&#038;a[]=2"> this guy </a> ]',
     
    12461211                        array(
    12471212                                '[/...]', // This would actually be ignored by the shortcode system.  The decision to not texturize it is intentional, if not correct.
    1248                                 '[/&#8230;]',
     1213                                '[/...]',
    12491214                        ),
    12501215                        array(
    12511216                                '[...]...[/...]', // These are potentially usable shortcodes.
    1252                                 '[&#8230;]&#8230;[/&#8230;]',
     1217                                '[...]&#8230;[/...]',
    12531218                        ),
    12541219                        array(
    12551220                                '[[...]]...[[/...]]', // Shortcode parsing will ignore the inner ]...[ part and treat this as a single escaped shortcode.
    1256                                 '[[&#8230;]]&#8230;[[/&#8230;]]',
     1221                                '[[...]]&#8230;[[/...]]',
    12571222                        ),
    12581223                        array(
    12591224                                '[[[...]]]...[[[/...]]]', // Again, shortcode parsing matches, but only the [[...] and [/...]] parts.
    1260                                 '[[[&#8230;]]]&#8230;[[[/&#8230;]]]',
     1225                                '[[[...]]]&#8230;[[[/...]]]',
    12611226                        ),
    12621227                        array(
     
    12661231                        array(
    12671232                                '[code]...[/code]]...', // These are potentially usable shortcodes.  Unfortunately, the meaning of [/code]] is ambiguous unless we run the entire shortcode regexp.
    1268                                 '[code]&#8230;[/code]]&#8230;', // This test would not pass in 3.9 because the extra brace was always ignored by texturize.
     1233                                '[code]...[/code]]...', // This test would not pass in 3.9 because the extra brace was always ignored by texturize.
    12691234                        ),
    12701235                        array(
     
    13811346                        ),
    13821347                        array(
    1383                                 '[Let\'s get crazy<input>[caption code="<a href=\'?a[]=100\'>hello</a>"]</input>world]', // caption shortcode is invalid here because it contains [] chars.
    1384                                 '[Let&#8217;s get crazy<input>[caption code=&#8221;<a href=\'?a[]=100\'>hello</a>&#8220;]</input>world]',
     1348                                '[Let\'s get crazy<input>[plugin code="<a href=\'?a[]=100\'>hello</a>"]</input>world]',
     1349                                '[Let&#8217;s get crazy<input>[plugin code="<a href=\'?a[]=100\'>hello</a>"]</input>world]',
    13851350                        ),
    13861351                );
     
    17511716                        array(
    17521717                                '<span>hello[code]---</span>',
    1753                                 '<span>hello[code]&#8212;</span>',
     1718                                '<span>hello[code]---</span>',
    17541719                        ),
    17551720                        array(
    17561721                                '[code]hello<span>---</span>',
    1757                                 '[code]hello<span>&#8212;</span>',
     1722                                '[code]hello<span>---</span>',
    17581723                        ),
    17591724                        array(
    17601725                                '[code]hello</span>---</span>',
    1761                                 '[code]hello</span>&#8212;</span>',
    1762                         ),
    1763                 );
    1764         }
    1765 
    1766         /**
    1767          * Test disabling shortcode texturization.
    1768          *
    1769          * @ticket 29557
    1770          * @dataProvider data_unregistered_shortcodes
    1771          */
    1772         function test_unregistered_shortcodes( $input, $output ) {
    1773                 add_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 );
    1774        
    1775                 $output = $this->assertEquals( $output, wptexturize( $input ) );
    1776        
    1777                 remove_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 );
    1778                 return $output;
    1779         }
    1780        
    1781         function filter_shortcodes( $disabled ) {
    1782                 $disabled[] = 'audio';
    1783                 return $disabled;
    1784         }
    1785 
    1786         function data_unregistered_shortcodes() {
    1787                 return array(
    1788                         array(
    1789                                 '[a]a--b[code]---[/code]a--b[/a]', // code is not a registered shortcode.
    1790                                 '[a]a&#8211;b[code]&#8212;[/code]a&#8211;b[/a]',
    1791                         ),
    1792                         array(
    1793                                 '[a]a--b[audio]---[/audio]a--b[/a]',
    1794                                 '[a]a&#8211;b[audio]---[/audio]a&#8211;b[/a]',
    1795                         ),
    1796                         array(
    1797                                 '[code ...]...[/code]', // code is not a registered shortcode.
    1798                                 '[code &#8230;]&#8230;[/code]',
    1799                         ),
    1800                         array(
    1801                                 '[hello ...]...[/hello]', // hello is not a registered shortcode.
    1802                                 '[hello &#8230;]&#8230;[/hello]',
    1803                         ),
    1804                         array(
    1805                                 '[...]...[/...]', // These are potentially usable shortcodes.
    1806                                 '[&#8230;]&#8230;[/&#8230;]',
    1807                         ),
    1808                         array(
    1809                                 '[gal>ery ...]',
    1810                                 '[gal>ery &#8230;]',
    1811                         ),
    1812                         array(
    1813                                 '[randomthing param="test"]',
    1814                                 '[randomthing param=&#8221;test&#8221;]',
    1815                         ),
    1816                         array(
    1817                                 '[[audio]...[/audio]...', // These are potentially usable shortcodes.  Unfortunately, the meaning of [[audio] is ambiguous unless we run the entire shortcode regexp.
    1818                                 '[[audio]&#8230;[/audio]&#8230;',
    1819                         ),
    1820                         array(
    1821                                 '[audio]...[/audio]]...', // These are potentially usable shortcodes.  Unfortunately, the meaning of [/audio]] is ambiguous unless we run the entire shortcode regexp.
    1822                                 '[audio]...[/audio]]...', // This test would not pass in 3.9 because the extra brace was always ignored by texturize.
    1823                         ),
    1824                         array(
    1825                                 '<span>hello[/audio]---</span>',
    1826                                 '<span>hello[/audio]&#8212;</span>',
    1827                         ),
    1828                         array(
    1829                                 '[/audio]hello<span>---</span>',
    1830                                 '[/audio]hello<span>&#8212;</span>',
    1831                         ),
    1832                         array(
    1833                                 '[audio]hello[/audio]---</span>',
    1834                                 '[audio]hello[/audio]&#8212;</span>',
    1835                         ),
    1836                         array(
    1837                                 '<span>hello</span>---[audio]',
    1838                                 '<span>hello</span>&#8212;[audio]',
    1839                         ),
    1840                         array(
    1841                                 '<span>hello[audio]---</span>',
    1842                                 '<span>hello[audio]---</span>',
    1843                         ),
    1844                         array(
    1845                                 '[audio]hello<span>---</span>',
    1846                                 '[audio]hello<span>---</span>',
    1847                         ),
    1848                         array(
    1849                                 '[audio]hello</span>---</span>',
    1850                                 '[audio]hello</span>---</span>',
     1726                                '[code]hello</span>---</span>',
    18511727                        ),
    18521728                );
Note: See TracChangeset for help on using the changeset viewer.