summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_test/cases/lib/exe/css_css_compress.test.php10
-rw-r--r--lib/exe/css.php16
-rw-r--r--lib/styles/style.css2
3 files changed, 24 insertions, 4 deletions
diff --git a/_test/cases/lib/exe/css_css_compress.test.php b/_test/cases/lib/exe/css_css_compress.test.php
index df5d4cba0..68d19fae8 100644
--- a/_test/cases/lib/exe/css_css_compress.test.php
+++ b/_test/cases/lib/exe/css_css_compress.test.php
@@ -29,6 +29,16 @@ class css_css_compress_test extends UnitTestCase {
$this->assertEqual(css_compress($text), '/* \\*/display:inline;/* */');
}
+ function test_hack2(){
+ $text = '/* min-height hack for Internet Explorer http://www.cssplay.co.uk/boxes/minheight.html */
+ /*\\*/
+ * html .page {
+ height: 450px;
+ }
+ /**/';
+ $this->assertEqual(css_compress($text), '/*\\*/* html .page{height:450px;}/**/');
+ }
+
function test_nl1(){
$text = "a{left:20px;\ntop:20px}";
$this->assertEqual(css_compress($text), 'a{left:20px;top:20px}');
diff --git a/lib/exe/css.php b/lib/exe/css.php
index 221e25801..74efe71b6 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -238,9 +238,8 @@ function css_compress($css){
$css = preg_replace('![\r\n\t ]+!',' ',$css);
$css = preg_replace('/ ?([:;,{}\/]) ?/','\\1',$css);
- // strip comments (ungreedy)
- // We keep very small comments to maintain typical browser hacks
- $css = preg_replace('#(/\*)((?!\*/).){4,}(\*/)#Us','',$css);
+ //strip comments through a callback
+ $css = preg_replace_callback('#(/\*)(.*?)(\*/)#s','css_comment_cb',$css);
// shorten colors
$css = preg_replace("/#([0-9a-fA-F]{1})\\1([0-9a-fA-F]{1})\\2([0-9a-fA-F]{1})\\3/", "#\\1\\2\\3",$css);
@@ -248,6 +247,17 @@ function css_compress($css){
return $css;
}
+/**
+ * Callback for css_compress()
+ *
+ * Keeps short comments (< 5 chars) to maintain typical browser hacks
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function css_comment_cb($matches){
+ if(strlen($matches[2]) > 4) return '';
+ return $matches[0];
+}
//Setup VIM: ex: et ts=4 enc=utf-8 :
?>
diff --git a/lib/styles/style.css b/lib/styles/style.css
index 4a223be4d..f86b47df0 100644
--- a/lib/styles/style.css
+++ b/lib/styles/style.css
@@ -3,7 +3,7 @@
* regardless of the used template. Templates can override them of course
*/
-div.clearer {clear: both; line-height: 0; height: 0;}
+div.clearer {clear: both; line-height: 0; height: 0; overflow:hidden;}
div.error{
background: #fcc url(../images/error.png) 0.5em 0px no-repeat;