Ticket #27587: prior-work.patch
File prior-work.patch, 3.3 KB (added by , 11 years ago) |
---|
-
src/wp-includes/formatting.php
1909 1909 */ 1910 1910 $src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() ); 1911 1911 1912 return sprintf( ' <img src="%s" alt="%s" class="wp-smiley" />', esc_url( $src_url ), esc_attr( $smiley ) );1912 return sprintf( '<img src="%s" alt="%s" class="wp-smiley" />', esc_url( $src_url ), esc_attr( $smiley ) ); 1913 1913 } 1914 1914 1915 1915 /** -
src/wp-includes/functions.php
2566 2566 */ 2567 2567 krsort($wpsmiliestrans); 2568 2568 2569 $wp_smiliessearch = '/((?:\s|^)'; 2569 $spaces = wp_spaces_regexp(); 2570 2571 // Begin first "subpattern" 2572 $wp_smiliessearch = '/(?<=' . $spaces . '|^)'; 2570 2573 2571 2574 $subchar = ''; 2572 2575 foreach ( (array) $wpsmiliestrans as $smiley => $img ) { … … 2576 2579 // new subpattern? 2577 2580 if ($firstchar != $subchar) { 2578 2581 if ($subchar != '') { 2579 $wp_smiliessearch .= ')(?=\s|$))|((?:\s|^)'; ; 2582 $wp_smiliessearch .= ')(?=' . $spaces . '|$)'; // End previous "subpattern" 2583 $wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern" 2580 2584 } 2581 2585 $subchar = $firstchar; 2582 2586 $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:'; … … 2586 2590 $wp_smiliessearch .= preg_quote($rest, '/'); 2587 2591 } 2588 2592 2589 $wp_smiliessearch .= ')(?= \s|$))/m';2593 $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m'; 2590 2594 2591 2595 } 2592 2596 -
tests/phpunit/tests/formatting/Smilies.php
275 275 276 276 $wpsmiliestrans = $orig_trans; // reset original translations array 277 277 } 278 } 279 No newline at end of file 278 279 /** 280 * Check that $wp_smiliessearch pattern will match smilies 281 * between spaces, but never capture those spaces. 282 * 283 * Further check that spaces aren't randomly deleted 284 * or added when replacing the text with an image. 285 * 286 * @ticket 22692 287 */ 288 function test_spaces_around_smilies() { 289 $nbsp = "\xC2\xA0"; 290 291 $input = array(); 292 $output = array(); 293 294 $input[] = 'My test :) smile'; 295 $output[] = array('test <img ', 'alt=":)"', ' /> smile'); 296 297 $input[] = 'My test ;) smile'; 298 $output[] = array('test <img ', 'alt=";)"', ' /> smile'); 299 300 $input[] = 'My test :) smile'; 301 $output[] = array('test <img ', 'alt=":)"', ' /> smile'); 302 303 $input[] = 'My test ;) smile'; 304 $output[] = array('test <img ', 'alt=";)"', ' /> smile'); 305 306 $input[] = "My test {$nbsp}:){$nbsp}smile"; 307 $output[] = array("test {$nbsp}<img ", 'alt=":)"', " />{$nbsp}smile"); 308 309 $input[] = "My test {$nbsp};){$nbsp}smile"; 310 $output[] = array("test {$nbsp}<img ", 'alt=";)"', " />{$nbsp}smile"); 311 312 foreach($input as $key => $in) { 313 $result = convert_smilies( $in ); 314 foreach($output[$key] as $out) { 315 316 // Each output element must appear in the results. 317 $this->assertContains( $out, $result ); 318 319 } 320 } 321 } 322 }