Permalink
Browse files

release 2.4.8-2

  • Loading branch information...
tubalmartin committed Nov 13, 2013
1 parent 9bff809 commit fb33d2ffd0963692747101330b175a80173ce21b
View
@@ -231,6 +231,13 @@ Values & notes: [pcre.recursion_limit documentation](http://php.net/manual/en/pc
## 6. Changelog
+### 2.4.8-2 13 Nov 2013
+
+* Chunk length reduced to 5000 chars (prevu¡iously 25.000 chars) in an effort to avoid PCRE backtrack limits (needs feedback).
+* Improvements for the @keyframes 0% step bug. Tests improved.

This comment has been minimized.

Show comment
Hide comment
@glensc

glensc Mar 17, 2014

Contributor

prevu¡iously some typo?

@glensc

glensc Mar 17, 2014

Contributor

prevu¡iously some typo?

+* Fix IE7 issue on matrix filters which browser accept whitespaces between Matrix parameters
+* LESS compiler upgraded to version 1.4.2
+
### 2.4.8-1 8 Aug 2013
* Fix for the @keyframes 0% step bug. Tests added.
View
@@ -1,7 +1,7 @@
<?php
/*!
- * cssmin.php rev ebaf67b 12/06/2013
+ * cssmin.php 2.4.8-2
* Author: Tubal Martin - http://tubalmartin.me/
* Repo: https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port
*
@@ -92,7 +92,7 @@ public function run($css = '', $linebreak_pos = FALSE)
// preserve strings so their content doesn't get accidentally minified
$css = preg_replace_callback('/(?:"(?:[^\\\\"]|\\\\.|\\\\)*")|'."(?:'(?:[^\\\\']|\\\\.|\\\\)*')/S", array($this, 'replace_string'), $css);
- // Let's divide css code in chunks of 25.000 chars aprox.
+ // Let's divide css code in chunks of 5.000 chars aprox.
// Reason: PHP's PCRE functions like preg_replace have a "backtrack limit"
// of 100.000 chars by default (php < 5.3.7) so if we're dealing with really
// long strings and a (sub)pattern matches a number of chars greater than
@@ -101,7 +101,7 @@ public function run($css = '', $linebreak_pos = FALSE)
$charset = '';
$charset_regexp = '/(@charset)( [^;]+;)/i';
$css_chunks = array();
- $css_chunk_length = 25000; // aprox size, not exact
+ $css_chunk_length = 5000; // aprox size, not exact
$start_index = 0;
$i = $css_chunk_length; // save initial iterations
$l = strlen($css);
@@ -113,7 +113,7 @@ public function run($css = '', $linebreak_pos = FALSE)
} else {
// chunk css code securely
while ($i < $l) {
- $i += 50; // save iterations. 500 checks for a closing curly brace }
+ $i += 50; // save iterations
if ($l - $start_index <= $css_chunk_length || $i >= $l) {
$css_chunks[] = $this->str_slice($css, $start_index);
break;
@@ -264,6 +264,9 @@ private function minify($css, $linebreak_pos)
// Normalize all whitespace strings to single spaces. Easier to work with that way.
$css = preg_replace('/\s+/', ' ', $css);
+ // Fix IE7 issue on matrix filters which browser accept whitespaces between Matrix parameters
+ $css = preg_replace_callback('/\s*filter\:\s*progid:DXImageTransform\.Microsoft\.Matrix\(([^\)]+)\)/', array($this, 'preserve_old_IE_specific_matrix_definition'), $css);
+
// Shorten & preserve calculations calc(...) since spaces are important
$css = preg_replace_callback('/calc(\(((?:[^\(\)]+|(?1))*)\))/i', array($this, 'replace_calc'), $css);
@@ -337,7 +340,7 @@ private function minify($css, $linebreak_pos)
$css = preg_replace('/(^|[^0-9])(?:0?\.)?0(?:em|ex|ch|rem|vw|vh|vm|vmin|cm|mm|in|px|pt|pc|%|deg|g?rad|m?s|k?hz)/iS', '${1}0', $css);
// 0% step in a keyframe? restore the % unit
- $css = preg_replace('/(@[a-z\-]*?keyframes.*?)0\{/iS', '${1}0%{', $css);
+ $css = preg_replace_callback('/(@[a-z\-]*?keyframes[^\{]*?\{)(.*?\}\s*\})/iS', array($this, 'replace_keyframe_zero'), $css);
// Replace 0 0; or 0 0 0; or 0 0 0 0; with 0.
$css = preg_replace('/\:0(?: 0){1,3}(;|\}| \!)/', ':0$1', $css);
@@ -376,6 +379,16 @@ private function minify($css, $linebreak_pos)
// Add "/" back to fix Opera -o-device-pixel-ratio query
$css = preg_replace('/'. self::QUERY_FRACTION .'/', '/', $css);
+ // Replace multiple semi-colons in a row by a single one
+ // See SF bug #1980989
+ $css = preg_replace('/;;+/', ';', $css);
+
+ // Restore new lines for /*! important comments
+ $css = preg_replace('/'. self::NL .'/', "\n", $css);
+
+ // Lowercase all uppercase properties
+ $css = preg_replace_callback('/(\{|\;)([A-Z\-]+)(\:)/', array($this, 'lowercase_properties'), $css);
+
// Some source control tools don't like it when files containing lines longer
// than, say 8000 characters, are checked in. The linebreak option is used in
// that case to split long lines after a specific column.
@@ -391,18 +404,8 @@ private function minify($css, $linebreak_pos)
}
}
- // Replace multiple semi-colons in a row by a single one
- // See SF bug #1980989
- $css = preg_replace('/;;+/', ';', $css);
-
- // Restore new lines for /*! important comments
- $css = preg_replace('/'. self::NL .'/', "\n", $css);
-
- // Lowercase all uppercase properties
- $css = preg_replace_callback('/(\{|\;)([A-Z\-]+)(\:)/', array($this, 'lowercase_properties'), $css);
-
- // restore preserved comments and strings
- for ($i = 0, $max = count($this->preserved_tokens); $i < $max; $i++) {
+ // restore preserved comments and strings in reverse order
+ for ($i = count($this->preserved_tokens) - 1; $i >= 0; $i--) {
$css = preg_replace('/' . self::TOKEN . $i . '___/', $this->preserved_tokens[$i], $css, 1);
}
@@ -585,6 +588,17 @@ private function replace_calc($matches)
return 'calc('. self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')';
}
+ private function preserve_old_IE_specific_matrix_definition($matches)
+ {
+ $this->preserved_tokens[] = $matches[1];
+ return 'filter:progid:DXImageTransform.Microsoft.Matrix(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')';
+ }
+
+ private function replace_keyframe_zero($matches)
+ {
+ return $matches[1] . preg_replace('/0\s*,/', '0%,', preg_replace('/\s*0\s*\{/', '0%{', $matches[2]));
+ }
+
private function rgb_to_hex($matches)
{
// Support for percentage values rgb(100%, 0%, 45%);
View
@@ -86,7 +86,7 @@ function stripslashes_deep($value) {
<div class="navbar">
<div class="navbar-inner">
<div class="container-fluid">
- <a class="brand" href="https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port">YUI CSS compressor - PHP <span class="version">v2.4.8-1</span></a>
+ <a class="brand" href="https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port">YUI CSS compressor - PHP <span class="version">v2.4.8-2</span></a>
</div>
</div>
</div>
@@ -116,7 +116,7 @@ function stripslashes_deep($value) {
<legend>LESS</legend>
<p class="control-group">
<label class="checkbox">
- <input type="checkbox" id="enable-less" value="1"> Enable compiler <span class="version">v1.4.1</span>
+ <input type="checkbox" id="enable-less" value="1"> Enable compiler <span class="version">v1.4.2</span>
</label>
</p>
</fieldset>
@@ -170,7 +170,7 @@ function stripslashes_deep($value) {
</div>
</div>
</div>
- <script type="text/javascript" src="third-party/less-1.4.1.min.js"></script>
+ <script type="text/javascript" src="third-party/less-1.4.2.min.js"></script>
<script type="text/javascript" src="third-party/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="third-party/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="scripts.js"></script>

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -5,4 +5,14 @@
@-o-keyframes anim{
0% { opacity: 0; }
100% { opacity: 1; }
+}
+@keyframes test {
+ 0% , 100% { opacity: 0; }
+}
+@keyframes test2 {
+ 0%, 100% { opacity: 0; }
+}
+@keyframes test3 {
+ 50% { opacity: 50 }
+ 100%, 0% { opacity: 0; }
}
@@ -1 +1 @@
-@keyframes anim{0%{opacity:0}100%{opacity:1}}@-o-keyframes anim{0%{opacity:0}100%{opacity:1}}
+@keyframes anim{0%{opacity:0}100%{opacity:1}}@-o-keyframes anim{0%{opacity:0}100%{opacity:1}}@keyframes test{0%,100%{opacity:0}}@keyframes test2{0%,100%{opacity:0}}@keyframes test3{50%{opacity:50}100%,0%{opacity:0}}
@@ -0,0 +1,8 @@
+.a {
+filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.9914448613738104, M12=-0.13052619222005157, M21=0.13052619222005157, M22=0.9914448613738104, sizingMethod='auto expand');
+}
+.b {
+ display: none;
+ filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.9914448613738104, M12=-0.13052619222005157, M21=0.13052619222005157, M22=0.9914448613738104, sizingMethod='auto expand');
+ vertical-align: bottom;
+}
@@ -0,0 +1 @@
+.a{filter:progid:DXImageTransform.Microsoft.Matrix(M11=0.9914448613738104, M12=-0.13052619222005157, M21=0.13052619222005157, M22=0.9914448613738104, sizingMethod='auto expand')}.b{display:none;filter:progid:DXImageTransform.Microsoft.Matrix(M11=0.9914448613738104, M12=-0.13052619222005157, M21=0.13052619222005157, M22=0.9914448613738104, sizingMethod='auto expand');vertical-align:bottom}
@@ -0,0 +1,4 @@
+.color_chip {
+ color: color: rgb(0%, 50%, 50%);
+ background: rgba(195, 198, 214, 0.85);
+}
@@ -0,0 +1 @@
+.color_chip{color: rgb(0%, 50%, 50%);background:rgba(195,198,214,0.85)}

0 comments on commit fb33d2f

Please sign in to comment.