Ticket #29557: miqro-29557.patch
File miqro-29557.patch, 5.1 KB (added by , 10 years ago) |
---|
-
src/wp-includes/formatting.php
28 28 * @return string The string replaced with html entities 29 29 */ 30 30 function wptexturize($text, $reset = false) { 31 global $wp_cockneyreplace ;31 global $wp_cockneyreplace, $shortcode_tags; 32 32 static $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements, 33 33 $default_no_texturize_tags, $default_no_texturize_shortcodes, $run_texturize = true; 34 34 … … 205 205 206 206 // Look for shortcodes and HTML elements. 207 207 208 $tagnames = array_keys( $shortcode_tags ); 209 $tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) ); 210 $tagregexp = "(?:$tagregexp)(?![\\w-])"; // Excerpt of get_shortcode_regex(). 211 208 212 $regex = '/(' // Capture the entire match. 209 213 . '<' // Find start of element. 210 214 . '(?(?=!--)' // Is this a comment? … … 215 219 . '|' 216 220 . '\[' // Find start of shortcode. 217 221 . '\[?' // Shortcodes may begin with [[ 222 . $tagregexp // Only match registered shortcodes, because performance. 218 223 . '(?:' 219 224 . '[^\[\]<>]' // Shortcodes do not contain other shortcodes. 220 225 . '|' -
tests/phpunit/tests/formatting/WPTexturize.php
11 11 12 12 function test_disable() { 13 13 $this->assertEquals('<pre>---</pre>', wptexturize('<pre>---</pre>')); 14 $this->assertEquals('[a]a–b[code]---[/code]a–b[/a]', wptexturize('[a]a--b[code]---[/code]a--b[/a]'));15 14 $this->assertEquals('<pre><code></code>--</pre>', wptexturize('<pre><code></code>--</pre>')); 16 15 17 16 $this->assertEquals( '<code>---</code>', wptexturize( '<code>---</code>' ) ); … … 1213 1212 '[/...]', 1214 1213 ), 1215 1214 array( 1216 '[...]...[/...]', // These are potentially usable shortcodes.1217 '[...]…[/...]',1218 ),1219 array(1220 '[[...]]...[[/...]]', // Shortcode parsing will ignore the inner ]...[ part and treat this as a single escaped shortcode.1221 '[[...]]…[[/...]]',1222 ),1223 array(1224 '[[[...]]]...[[[/...]]]', // Again, shortcode parsing matches, but only the [[...] and [/...]] parts.1225 '[[[...]]]…[[[/...]]]',1226 ),1227 array(1228 '[[code]...[/code]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [[code] is ambiguous unless we run the entire shortcode regexp.1229 '[[code]…[/code]…',1230 ),1231 array(1232 '[code]...[/code]]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [/code]] is ambiguous unless we run the entire shortcode regexp.1233 '[code]...[/code]]...', // This test would not pass in 3.9 because the extra brace was always ignored by texturize.1234 ),1235 array(1236 1215 '[gal>ery ...]', 1237 1216 '[gal>ery …]', 1238 1217 ), … … 1344 1323 '[ but also catches the <b>styled "[quote]" here</b> ]', 1345 1324 '[ but also catches the <b>styled “[quote]” here</b> ]', 1346 1325 ), 1347 array(1348 '[Let\'s get crazy<input>[plugin code="<a href=\'?a[]=100\'>hello</a>"]</input>world]',1349 '[Let’s get crazy<input>[plugin code="<a href=\'?a[]=100\'>hello</a>"]</input>world]',1350 ),1351 1326 ); 1352 1327 } 1353 1328 … … 1697 1672 '<code>hello</span>---</span>', 1698 1673 '<code>hello</span>---</span>', 1699 1674 ), 1675 ); 1676 } 1677 1678 /** 1679 * These tests are obsolete and will fail. 1680 * 1681 * @ticket 29557 1682 * @dataProvider data_unregistered_shortcodes 1683 */ 1684 function test_unregistered_shortcodes( $input, $output ) { 1685 return $this->assertEquals( $output, wptexturize( $input ) ); 1686 } 1687 1688 function data_unregistered_shortcodes() { 1689 return array( 1700 1690 array( 1691 '[a]a--b[code]---[/code]a--b[/a]', 1692 '[a]a–b[code]---[/code]a–b[/a]', 1693 ), 1694 array( 1695 '[...]...[/...]', // These are potentially usable shortcodes. 1696 '[...]…[/...]', 1697 ), 1698 array( 1699 '[[...]]...[[/...]]', // Shortcode parsing will ignore the inner ]...[ part and treat this as a single escaped shortcode. 1700 '[[...]]…[[/...]]', 1701 ), 1702 array( 1703 '[[[...]]]...[[[/...]]]', // Again, shortcode parsing matches, but only the [[...] and [/...]] parts. 1704 '[[[...]]]…[[[/...]]]', 1705 ), 1706 array( 1707 '[[code]...[/code]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [[code] is ambiguous unless we run the entire shortcode regexp. 1708 '[[code]…[/code]…', 1709 ), 1710 array( 1711 '[code]...[/code]]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [/code]] is ambiguous unless we run the entire shortcode regexp. 1712 '[code]...[/code]]...', // This test would not pass in 3.9 because the extra brace was always ignored by texturize. 1713 ), 1714 array( 1715 '[Let\'s get crazy<input>[plugin code="<a href=\'?a[]=100\'>hello</a>"]</input>world]', 1716 '[Let’s get crazy<input>[plugin code="<a href=\'?a[]=100\'>hello</a>"]</input>world]', 1717 ), 1718 array( 1701 1719 '<span>hello[/code]---</span>', 1702 1720 '<span>hello[/code]—</span>', 1703 1721 ),