Ticket #35293: 35293.2.patch
| File 35293.2.patch, 3.0 KB (added by , 10 years ago) |
|---|
-
src/wp-includes/formatting.php
5100 5100 5101 5101 // If it's not a tag and not in ignore block. 5102 5102 if ( '' == $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] ) { 5103 // Flags. 5103 5104 $matches = array(); 5104 5105 if ( preg_match_all( '/(DZ(e[6-9a-f]|f[0-9a-f]);){2}/', $content, $matches ) ) { 5105 5106 if ( ! empty( $matches[0] ) ) { … … 5115 5116 } 5116 5117 5117 5118 // Loosely match the Emoji Unicode range. 5118 $ regex = '/(&#x[2-3][0-9a-f]{3};|[1-6][0-9a-f]{2};)/';5119 $unicode_range = '(&#x[2-3][0-9a-f]{3};|[1-9][0-9a-f]{2};)'; 5119 5120 5121 // Diversity. 5120 5122 $matches = array(); 5121 if ( preg_match_all( $regex, $content, $matches ) ) {5123 if ( preg_match_all( "/($unicode_rangeἿ[b-f];)/", $content, $matches ) ) { 5122 5124 if ( ! empty( $matches[1] ) ) { 5123 5125 foreach ( $matches[1] as $emoji ) { 5126 $chars = str_replace( array( '&#x', ';'), '', $emoji ); 5127 5128 list( $char1, $char2 ) = str_split( $chars, 5 ); 5129 $entity = sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $char1 . '-' . $char2 . $ext, html_entity_decode( $emoji ) ); 5130 5131 $content = str_replace( $emoji, $entity, $content ); 5132 } 5133 } 5134 } 5135 5136 $matches = array(); 5137 if ( preg_match_all( "/$unicode_range/", $content, $matches ) ) { 5138 if ( ! empty( $matches[1] ) ) { 5139 foreach ( $matches[1] as $emoji ) { 5124 5140 $char = str_replace( array( '&#x', ';'), '', $emoji ); 5125 5141 $entity = sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $char . $ext, html_entity_decode( $emoji ) ); 5126 5142 -
tests/phpunit/tests/formatting/Emoji.php
65 65 remove_filter( 'emoji_url', array( $this, '_filtered_emoji_png_cdn' ) ); 66 66 } 67 67 68 /** 69 * @ticket 35293 70 */ 71 public function test_wp_staticize_emoji() { 72 $this->assertContains( 'https://s.w.org/images/core/emoji/2/72x72/1f60e.png', wp_staticize_emoji( '😎' ) ); // Unicode 6: smiling face with sunglasses 73 $this->assertContains( 'https://s.w.org/images/core/emoji/2/72x72/1f44d-1f3fb.png', wp_staticize_emoji( '👍🏻' ) ); // Unicode 8: thumbs up sign 74 $this->assertContains( 'https://s.w.org/images/core/emoji/2/72x72/1f923.png', wp_staticize_emoji( '🤣' ) ); // Unicode 9: rolling on the floor laughing 75 } 76 77 /** 78 * @ticket 352932 79 */ 80 public function test_wp_encode_emoji() { 81 $this->assertSame( '😎', wp_encode_emoji( '😎' ) ); // Unicode 6: smiling face with sunglasses 82 $this->assertSame( '👍🏻', wp_encode_emoji( '👍🏻' ) ); // Unicode 8: thumbs up sign 83 $this->assertSame( '🤣', wp_encode_emoji( '🤣' ) ); // Unicode 9: rolling on the floor laughing 84 } 68 85 }