Ticket #27588: miqro-27588.2.patch
File miqro-27588.2.patch, 3.3 KB (added by , 9 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 … … 3860 3854 static $spaces; 3861 3855 3862 3856 if ( empty( $spaces ) ) { 3857 /** 3858 * Regexp for common whitespace characters. 3859 * 3860 * This string is substituted for the \s sequence as needed in regular expressions. 3861 * For websites not written in English, different characters may represent whitespace. 3862 * For websites not encoded in UTF-8, the 0xC2 0xA0 sequence may not be in use. 3863 * 3864 * @since 4.0.0 3865 * 3866 * @param string $spaces 3867 */ 3863 3868 $spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0| ' ); 3864 3869 } 3865 3870 3866 3871 return $spaces; 3867 } 3868 No newline at end of file 3872 } -
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 }