--- common.inc 2009-12-17 01:47:10.000000000 +0500 +++ common.inc 2010-02-18 18:26:31.000000000 +0500 @@ -2009,8 +2009,11 @@ function drupal_load_stylesheet($file, $ // Perform some safe CSS optimizations. $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); + $contents = preg_replace_callback( + '', # Match all comment blocks and feed them to _proccess_comment(). + "_proccess_comment", + $contents); } // Change back directory. @@ -2021,6 +2024,36 @@ function drupal_load_stylesheet($file, $ } /** + * Implements comment strip logic. + * + * This is the callback function for the preg_replace_callback() used in + * drupal_load_stylesheet_content(). Support for comment hacks is implemented here. + */ +function _proccess_comment($matches) { + static $keep_nextone = FALSE; + // End of IE-Mac hack, keep it. + if ($keep_nextone) { + $keep_nextone = FALSE; + return $matches[0]; + } + else { + switch (strrpos($matches[0], '\\')) { + // No backslash, strip it. + case FALSE : + return ''; + break; + // Ends with \*/ so is a multi line IE-Mac hack, keep this and the next one. + case drupal_strlen($matches[0])-3 : + $keep_nextone = TRUE; + // Fall through to default case. + // Single line IE-Mac hack, keep this. + default : + return $matches[0]; + } + } +} + +/** * Loads stylesheets recursively and returns contents with corrected paths. * * This function is used for recursive loading of stylesheets and