diff options
author | Bartosz DziewoĆski <matma.rex@gmail.com> | 2014-09-20 23:26:13 +0200 |
---|---|---|
committer | Krinkle <krinklemail@gmail.com> | 2014-09-23 22:47:54 +0000 |
commit | 4c01f8b2bc45da2fa4df29b8dfb14202bb2b4713 (patch) | |
tree | 56c84e4ddf3b54b7f519c2b3107c750fc1c97f0f /includes/libs/CSSMin.php | |
parent | 6f14c88a0b42396a091560c65f4c9bb9ef47fe9e (diff) | |
download | mediawikicore-4c01f8b2bc45da2fa4df29b8dfb14202bb2b4713.tar.gz mediawikicore-4c01f8b2bc45da2fa4df29b8dfb14202bb2b4713.zip |
Make "/*@noflip*/ /*@embed*/" annotation work without CSSJanus hacks
This reverts most of commit 2d842f14250646475b5c2ffa2fe4f5a131f94236,
leaving only the test added in it, and reimplements the same
functionality better.
Instead of stripping /*@noflip*/ annotations in CSSJanus, which is
incompatible with other implementations that preserve it, extend
CSSMin to allow other CSS comments to be present before the
rule-global @embed annotation. (This required making the regex logic
in it even worse than it was, but it's actually slightly less terrible
than I expected it would be. Good thing we have tests!)
Bug: 69698
Change-Id: I58603ef64f7d7cdc6461b34721a4d6b15f15ad79
Diffstat (limited to 'includes/libs/CSSMin.php')
-rw-r--r-- | includes/libs/CSSMin.php | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index dcaa6857a271..c69e79f5b23e 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -200,10 +200,9 @@ class CSSMin { $remote = substr( $remote, 0, -1 ); } - // Replace all comments by a placeholder so they will not interfere - // with the remapping - // Warning: This will also catch on anything looking like the start of - // a comment between quotation marks (e.g. "foo /* bar"). + // Replace all comments by a placeholder so they will not interfere with the remapping. + // Warning: This will also catch on anything looking like the start of a comment between + // quotation marks (e.g. "foo /* bar"). $comments = array(); $placeholder = uniqid( '', true ); @@ -226,12 +225,13 @@ class CSSMin { $source = preg_replace_callback( $pattern, - function ( $matchOuter ) use ( $local, $remote, $embedData ) { + function ( $matchOuter ) use ( $local, $remote, $embedData, $placeholder ) { $rule = $matchOuter[0]; - // Check for global @embed comment and remove it + // Check for global @embed comment and remove it. Allow other comments to be present + // before @embed (they have been replaced with placeholders at this point). $embedAll = false; - $rule = preg_replace( '/^(\s*)' . CSSMin::EMBED_REGEX . '\s*/', '$1', $rule, 1, $embedAll ); + $rule = preg_replace( '/^((?:\s+|' . $placeholder . '(\d+)x)*)' . CSSMin::EMBED_REGEX . '\s*/', '$1', $rule, 1, $embedAll ); // Build two versions of current rule: with remapped URLs // and with embedded data: URIs (where possible). |