Title: Bug in CSSMin.php
Last modified: August 21, 2016

---

# Bug in CSSMin.php

 *  Resolved [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/bug-in-cssminphp/)
 * I’ve stumbled upon a longstanding bug in CSSMin.php regarding [@keyframe](https://wordpress.org/support/users/keyframe/)
   rules, resulting in invalid CSS code after minification. Here’s a patch:
 *     ```
       --- CssMin.php.old      2014-07-31 23:54:20.988623978 +0200
       +++ CssMin.php  2014-08-01 00:13:01.920546691 +0200
       @@ -465,7 +465,7 @@
                                       }
                               elseif ($class === "CssAtKeyframesStartToken")
                                       {
       -                               $r[] = $indent . "@keyframes \"" . $token->Name . "\"";
       +                               $r[] = $indent . "@keyframes " . $token->Name . "";
                                       $r[] = $this->indent . $indent . "{";
                                       $level++;
                                       }
       @@ -1840,7 +1840,7 @@
                                       }
                               elseif ($class === "CssAtKeyframesStartToken")
                                       {
       -                               $r[] = $indent . "@keyframes \"" . $token->Name . "\" {";
       +                               $r[] = $indent . "@keyframes " . $token->Name . " {";
                                       $level++;
                                       }
                               elseif ($class === "CssAtMediaStartToken")
       @@ -3325,7 +3325,7 @@
               public function apply(array &$tokens)
                       {
                       $r = 0;
       -               $transformations = array("-moz-keyframes", "-webkit-keyframes");
       +               $transformations = array("-moz-keyframes", "-webkit-keyframes", "-o-keyframes", "-ms-keyframes");
                       for ($i = 0, $l = count($tokens); $i < $l; $i++)
                               {
                               if (get_class($tokens[$i]) === "CssAtKeyframesStartToken")
       @@ -4435,7 +4435,7 @@
                */
               public function __toString()
                       {
       -               return "@" . $this->AtRuleName . " \"" . $this->Name . "\"{";
       +               return "@" . $this->AtRuleName . " " . $this->Name . "{";
                       }
               }
   
       @@ -4574,6 +4574,23 @@
                               $this->parser->clearBuffer();
                               return $index + 15;
                               }
       +               // Start of @keyframes at-rule block (@-ms-keyframes)
       +               else if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 14)) === "@-ms-keyframes")
       +               {
       +                       $this->atRuleName = "-ms-keyframes";
       +                       $this->parser->pushState("T_AT_KEYFRAMES::NAME");
       +                       $this->parser->clearBuffer();
       +                       return $index + 14;
       +                       }
       +               // Start of @keyframes at-rule block (@-o-keyframes)
       +               else if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 13)) === "@-o-keyframes")
       +                       {
       +                       $this->atRuleName = "-o-keyframes";
       +                       $this->parser->pushState("T_AT_KEYFRAMES::NAME");
       +                       $this->parser->clearBuffer();
       +                       return $index + 13;
       +                       }
       +
                       // Start of @keyframes at-rule block (@-webkit-keyframes)
                       elseif ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 18)) === "@-webkit-keyframes")
                               {
       ```
   
 * [https://wordpress.org/plugins/assetsminify/](https://wordpress.org/plugins/assetsminify/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Alessandro Carbone](https://wordpress.org/support/users/alecarbo/)
 * (@alecarbo)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/bug-in-cssminphp/#post-5154217)
 * Released on 1.2.3

Viewing 1 replies (of 1 total)

The topic ‘Bug in CSSMin.php’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/assetsminify.svg)
 * [AssetsMinify](https://wordpress.org/plugins/assetsminify/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/assetsminify/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/assetsminify/)
 * [Active Topics](https://wordpress.org/support/plugin/assetsminify/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/assetsminify/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/assetsminify/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Alessandro Carbone](https://wordpress.org/support/users/alecarbo/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/bug-in-cssminphp/#post-5154217)
 * Status: resolved