WordPress.org

Make WordPress Core

Changeset 36410


Ignore:
Timestamp:
01/27/2016 10:10:58 AM (5 years ago)
Author:
dd32
Message:

Emoji: Work around a mod_security rule which prevents pages with 4 or more instances of String.fromCharCode( from being served.

Merges [36359] to the 4.4 branch.
Fixes #35412.

Location:
branches/4.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4

  • branches/4.4/src/wp-includes/js/wp-emoji-loader.js

    r36161 r36410  
    1414        var canvas = document.createElement( 'canvas' ),
    1515            context = canvas.getContext && canvas.getContext( '2d' ),
     16            stringFromCharCode = String.fromCharCode,
    1617            tone;
    1718
     
    3839             * to a larger image (4-5KB data URL).
    3940             */
    40             context.fillText( String.fromCharCode( 55356, 56806, 55356, 56826 ), 0, 0 );
     41            context.fillText( stringFromCharCode( 55356, 56806, 55356, 56826 ), 0, 0 );
    4142            return canvas.toDataURL().length > 3000;
    4243        } else if ( 'diversity' === type ) {
     
    4647             * compares if the emoji rendering has changed.
    4748             */
    48             context.fillText( String.fromCharCode( 55356, 57221 ), 0, 0 );
     49            context.fillText( stringFromCharCode( 55356, 57221 ), 0, 0 );
    4950            tone = context.getImageData( 16, 16, 1, 1 ).data.toString();
    50             context.fillText( String.fromCharCode( 55356, 57221, 55356, 57343 ), 0, 0 );
     51            context.fillText( stringFromCharCode( 55356, 57221, 55356, 57343 ), 0, 0 );
    5152            // Chrome has issues comparing arrays, so we compare it as a  string, instead.
    5253            return tone !== context.getImageData( 16, 16, 1, 1 ).data.toString();
     
    5859                 * as an empty square, so the center pixel will be blank.
    5960                 */
    60                 context.fillText( String.fromCharCode( 55357, 56835 ), 0, 0 );
     61                context.fillText( stringFromCharCode( 55357, 56835 ), 0, 0 );
    6162            } else {
    6263                /*
     
    6465                 * that the Unicode Consortium have made in years: the burrito.
    6566                 */
    66                 context.fillText( String.fromCharCode( 55356, 57135 ), 0, 0 );
     67                context.fillText( stringFromCharCode( 55356, 57135 ), 0, 0 );
    6768            }
    6869            return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0;
Note: See TracChangeset for help on using the changeset viewer.