From dddfbfa1d3f1ea7347984f076ecbdc07f88e99c3 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 20 Jan 2016 07:40:28 +0000 Subject: [PATCH] Emoji: Work around a `mod_security` rule which prevents pages with 4 or more instances of `String.fromCharCode(` from being served. Fixes #35412 for trunk. Built from https://develop.svn.wordpress.org/trunk@36359 git-svn-id: http://core.svn.wordpress.org/trunk@36326 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 2 +- wp-includes/js/wp-emoji-loader.js | 11 ++++++----- wp-includes/js/wp-emoji-loader.min.js | 2 +- wp-includes/version.php | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 7257713a4f..b3f1506ab3 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -4579,7 +4579,7 @@ function print_emoji_detection_script() { ?> 3000; } else if ( 'diversity' === type ) { /* @@ -45,9 +46,9 @@ * emoji with no skin tone specified (in this case, Santa). It then adds a skin tone, and * compares if the emoji rendering has changed. */ - context.fillText( String.fromCharCode( 55356, 57221 ), 0, 0 ); + context.fillText( stringFromCharCode( 55356, 57221 ), 0, 0 ); tone = context.getImageData( 16, 16, 1, 1 ).data.toString(); - context.fillText( String.fromCharCode( 55356, 57221, 55356, 57343 ), 0, 0 ); + context.fillText( stringFromCharCode( 55356, 57221, 55356, 57343 ), 0, 0 ); // Chrome has issues comparing arrays, so we compare it as a string, instead. return tone !== context.getImageData( 16, 16, 1, 1 ).data.toString(); } else { @@ -57,13 +58,13 @@ * center pixel. In browsers that don't support emoji, the character will be rendered * as an empty square, so the center pixel will be blank. */ - context.fillText( String.fromCharCode( 55357, 56835 ), 0, 0 ); + context.fillText( stringFromCharCode( 55357, 56835 ), 0, 0 ); } else { /* * To check for Unicode 8 support, let's try rendering the most important advancement * that the Unicode Consortium have made in years: the burrito. */ - context.fillText( String.fromCharCode( 55356, 57135 ), 0, 0 ); + context.fillText( stringFromCharCode( 55356, 57135 ), 0, 0 ); } return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0; } diff --git a/wp-includes/js/wp-emoji-loader.min.js b/wp-includes/js/wp-emoji-loader.min.js index fb5d949c25..9579e8f9e4 100644 --- a/wp-includes/js/wp-emoji-loader.min.js +++ b/wp-includes/js/wp-emoji-loader.min.js @@ -1 +1 @@ -!function(a,b,c){function d(a){var c,d=b.createElement("canvas"),e=d.getContext&&d.getContext("2d");return e&&e.fillText?(e.textBaseline="top",e.font="600 32px Arial","flag"===a?(e.fillText(String.fromCharCode(55356,56806,55356,56826),0,0),d.toDataURL().length>3e3):"diversity"===a?(e.fillText(String.fromCharCode(55356,57221),0,0),c=e.getImageData(16,16,1,1).data.toString(),e.fillText(String.fromCharCode(55356,57221,55356,57343),0,0),c!==e.getImageData(16,16,1,1).data.toString()):("simple"===a?e.fillText(String.fromCharCode(55357,56835),0,0):e.fillText(String.fromCharCode(55356,57135),0,0),0!==e.getImageData(16,16,1,1).data[0])):!1}function e(a){var c=b.createElement("script");c.src=a,c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g;c.supports={simple:d("simple"),flag:d("flag"),unicode8:d("unicode8"),diversity:d("diversity")},c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.simple&&c.supports.flag&&c.supports.unicode8&&c.supports.diversity||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings); \ No newline at end of file +!function(a,b,c){function d(a){var c,d=b.createElement("canvas"),e=d.getContext&&d.getContext("2d"),f=String.fromCharCode;return e&&e.fillText?(e.textBaseline="top",e.font="600 32px Arial","flag"===a?(e.fillText(f(55356,56806,55356,56826),0,0),d.toDataURL().length>3e3):"diversity"===a?(e.fillText(f(55356,57221),0,0),c=e.getImageData(16,16,1,1).data.toString(),e.fillText(f(55356,57221,55356,57343),0,0),c!==e.getImageData(16,16,1,1).data.toString()):("simple"===a?e.fillText(f(55357,56835),0,0):e.fillText(f(55356,57135),0,0),0!==e.getImageData(16,16,1,1).data[0])):!1}function e(a){var c=b.createElement("script");c.src=a,c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g;c.supports={simple:d("simple"),flag:d("flag"),unicode8:d("unicode8"),diversity:d("diversity")},c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.simple&&c.supports.flag&&c.supports.unicode8&&c.supports.diversity||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index de8fd0002a..f77927edfe 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-alpha-36352'; +$wp_version = '4.5-alpha-36359'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.