CSS aggregation removes ie-mac hack which is being used in defaults.css.
// from defaults.css
$contents = <<<EOS
.clearfix {
display: inline-block;
}
/* Hides from IE-mac \*/
* html .clearfix {
height: 1%;
}
.clearfix {
display: block;
}
/* End hide from IE-mac */
EOS;
// from drupal_load_stylesheet_content()
$contents = preg_replace('{
(?<=\\\\\*/)([^/\*]+/\*)([^\*/]+\*/) # Add a backslash also at the end ie-mac hack comment, so the next pass will not touch it.
# The added backshlash does not affect the effectiveness of the hack.
}x', '\1\\\\\2', $contents);
$contents = preg_replace('<
\s*([@{}:;,]|\)\s|\s\()\s* | # Remove whitespace around separators, but keep space around parentheses.
/\*[^*\\\\]*\*+([^/*][^*]*\*+)*/ | # Remove comments that are not CSS hacks.
>x', '\1', $contents);
echo $contents;
Result:
.clearfix{display:inline-block;}/* Hides from IE-mac \*/ * html .clearfix{height:1%;}.clearfix{display:block;}
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | cssregexps3.patch | 12.16 KB | casey |
| #8 | cssregexps2.patch | 5.27 KB | casey |
| #6 | cssregexps.patch | 2.69 KB | casey |
| #6 | test.txt | 2.83 KB | casey |
| #5 | common.inc-5.patch | 934 bytes | Tri |
Comments
Comment #1
casey commentedComment #2
casey commented#444228: Optimize CSS option causes php cgi to segfault in pcre function "match"
Comment #3
damien tournoud commentedI just reopened the other one.
Comment #4
Tri commentedThe problem is here
It has to be rewritten so it will match multi-line blocks ever if they contain a star.
I will look into this and get back.
Comment #5
Tri commentedThe attached patch fixes it. Now it doesn't strip the end ie-mac hack comment even if the hack css rules contain a star.
Comment #6
casey commentedThis still fails on the ie-mac feed hack:
I created another version and used this file to test against: http://code.google.com/p/minify/source/browse/trunk/min_unit_tests/_test.... It only fails on nav4 hack (nobody uses that one anymore) and Tantek's midpass hack (which is too complicated anyway).
Also added some extra whitespace removals.
Comment #8
casey commentedForgot to update tests.
Also improved the code, comments in strings are handled correctly now (and Tantek's midpass hack does pass).
Comment #9
casey commentedComment #10
rfaysubscribing
Comment #11
casey commented+ test and some improvements.
Test in this patch does however failes due to #646862: CSS aggregate removes @import rules when not properly resolved.
Comment #13
casey commentedIn #641472: Fix CSS Aggregator, I am trying to fix all issues regarding CSS aggregation.
Comment #14
casey commentedOk, back to patch of Tri in #5. The patch works.
The IE-Mac CSS hack applies to IE5/Win and IE/Mac 5.0 & 5.1. The hack doesn't apply to IE/Mac 5.2. Latest version is 5.2.3 and originated from June 16, 2003.
The multi-line IE-Mac CSS hack is being used in modules/system/defaults.css. Current CSS aggregation removes the comments from that stylesheet. If support for that browsers should be kept, patch in #5 should go in.
But maybe we should just remove that hack from defaults.css.
Comment #15
Tri commentedI have found out that patch from #5 removes the multi-line ie-mac hack end comment when the hack rules contain a
/also, so it's getting too complex to solve it through regexps.Meanwhile, Gábor Hojtsy suggests here #444228: Optimize CSS option causes php cgi to segfault in pcre function "match" (#89) that any action about this issue should take place at that thread. So I am marking this (again) as duplicate of #444228: Optimize CSS option causes php cgi to segfault in pcre function "match", and I will post a new patch there.