Ticket #27588: prior-work.patch
File prior-work.patch, 3.3 KB (added by , 10 years ago) |
---|
-
src/wp-includes/formatting.php
73 73 $static_characters = array_merge( array( '---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)' ), $cockney ); 74 74 $static_replacements = array_merge( array( $em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); 75 75 76 /* 77 * Regex for common whitespace characters. 78 * 79 * By default, spaces include new lines, tabs, nbsp entities, and the UTF-8 nbsp. 80 * This is designed to replace the PCRE \s sequence. In #WP22692, that sequence 81 * was found to be unreliable due to random inclusion of the A0 byte. 82 */ 83 $spaces = '[\r\n\t ]|\xC2\xA0| '; 76 $spaces = wp_spaces_regexp(); 84 77 85 78 86 79 // Pattern-based replacements of characters. … … 361 354 } 362 355 363 356 $tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) ); 357 $spaces = wp_spaces_regexp(); 364 358 365 359 $pattern = 366 360 '/' 367 361 . '<p>' // Opening paragraph 368 . ' \\s*+'// Optional leading whitespace362 . '(?:' . $spaces . ')*+' // Optional leading whitespace 369 363 . '(' // 1: The shortcode 370 364 . '\\[' // Opening bracket 371 365 . "($tagregexp)" // 2: Shortcode name … … 390 384 . ')?' 391 385 . ')' 392 386 . ')' 393 . ' \\s*+'// optional trailing whitespace387 . '(?:' . $spaces . ')*+' // optional trailing whitespace 394 388 . '<\\/p>' // closing paragraph 395 389 . '/s'; 396 390 … … 3825 3819 3826 3820 return false; 3827 3821 } 3822 3823 /** 3824 * Returns the regexp for common whitespace characters. 3825 * 3826 * By default, spaces include new lines, tabs, nbsp entities, and the UTF-8 nbsp. 3827 * This is designed to replace the PCRE \s sequence. In ticket #22692, that 3828 * sequence was found to be unreliable due to random inclusion of the A0 byte. 3829 * 3830 * @since 4.0.0 3831 * 3832 * @return string The spaces regexp. 3833 */ 3834 function wp_spaces_regexp() { 3835 static $spaces; 3836 3837 if (empty($spaces)) { 3838 $spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0| ' ); 3839 } 3840 3841 return $spaces; 3842 } -
tests/phpunit/tests/shortcode.php
373 373 remove_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts2' ), 10, 3 ); 374 374 } 375 375 376 /** 377 * Check that shortcode_unautop() will always recognize spaces around shortcodes. 378 * 379 * @ticket 22692 380 */ 381 function test_spaces_around_shortcodes() { 382 $nbsp = "\xC2\xA0"; 383 384 $input = array(); 385 386 $input[] = "<p>[gallery ids=\"37,15,11\"]</p>"; 387 $input[] = "<p> [gallery ids=\"37,15,11\"] </p>"; 388 $input[] = "<p> {$nbsp}[gallery ids=\"37,15,11\"] {$nbsp}</p>"; 389 $input[] = "<p> [gallery ids=\"37,15,11\"] </p>"; 390 391 $output = "[gallery ids=\"37,15,11\"]"; 392 393 foreach($input as $in) { 394 $this->assertEquals( $output, shortcode_unautop( $in ) ); 395 } 396 } 376 397 }