From 9bdf4fe1e98adc0624a92132e2eede8cb50b5617 Mon Sep 17 00:00:00 2001 From: Peter Dias Date: Wed, 13 Jan 2021 10:20:15 +0800 Subject: [PATCH] MDL-70291 core: Add custom moodle patch to minify --- lib/minify/matthiasmullie-minify/src/CSS.php | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/minify/matthiasmullie-minify/src/CSS.php b/lib/minify/matthiasmullie-minify/src/CSS.php index 89fcf1bbb13..e00856f6003 100644 --- a/lib/minify/matthiasmullie-minify/src/CSS.php +++ b/lib/minify/matthiasmullie-minify/src/CSS.php @@ -636,7 +636,35 @@ class CSS extends Minify return $placeholder; }; + // Moodle-specific change MDL-68191 starts. + /* This was the old code: $this->registerPattern('/\n?\/\*(!|.*?@license|.*?@preserve).*?\*\/\n?/s', $callback); + */ + // This is the new, more accurate and faster regex. + $this->registerPattern('/ + # optional newline + \n? + + # start comment + \/\* + + # comment content + (?: + # either starts with an ! + ! + | + # or, after some number of characters which do not end the comment + (?:(?!\*\/).)*? + + # there is either a @license or @preserve tag + @(?:license|preserve) + ) + + # then match to the end of the comment + .*?\*\/\n? + + /ixs', $callback); + // Moodle-specific change MDL-68191. $this->registerPattern('/\/\*.*?\*\//s', ''); }