From 44def763067c47c92acf7608bda1c1a5234a27fa Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 19 Jun 2020 22:06:28 +0000 Subject: [PATCH] Build/Test Tools: Replace the banner text from `wp-emoji-loader.min.js` in `formatting.php` during build process. This ensures that `/*! This file is auto-generated */` comment is not included on front end as part of the inline Emoji detection script. Follow-up to [41271], [46589]. Props superpoincare, SergeyBiryukov. Fixes #49861. git-svn-id: https://develop.svn.wordpress.org/trunk@48096 602fd350-edb4-49c9-b593-d223f7449a82 --- Gruntfile.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 54c041aa41..7d820e1075 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1031,7 +1031,7 @@ module.exports = function(grunt) { patterns: [ { match: /\/\/ START: emoji arrays[\S\s]*\/\/ END: emoji arrays/g, - replacement: function () { + replacement: function() { var regex, files, partials, partialsSet, entities, emojiArray; @@ -1057,7 +1057,7 @@ module.exports = function(grunt) { entities = entities.replace( /-/g, '' ); // Sort the entities list by length, so the longest emoji will be found first. - emojiArray = entities.split( '\n' ).sort( function ( a, b ) { + emojiArray = entities.split( '\n' ).sort( function( a, b ) { return b.length - a.length; } ); @@ -1097,6 +1097,26 @@ module.exports = function(grunt) { dest: SOURCE_DIR + 'wp-includes/' } ] + }, + emojiBannerText: { + options: { + patterns: [ + { + match: new RegExp( '\\s*' + BANNER_TEXT.replace( /[\/\*\!]/g, '\\$&' ) ), + replacement: '' + } + ] + }, + files: [ + { + expand: true, + flatten: true, + src: [ + BUILD_DIR + 'wp-includes/formatting.php' + ], + dest: BUILD_DIR + 'wp-includes/' + } + ] } }, _watch: { @@ -1419,6 +1439,7 @@ module.exports = function(grunt) { 'build:css', 'includes:emoji', 'includes:embed', + 'replace:emojiBannerText' ] ); } } );