← All changes
|
classes/external/php/yui-php-cssmin-bundled/Minifier.php
+6
-3
2.7.6
→
trunk
View file →
| @@ -604,10 +604,13 @@ | ||
| 604 | 604 | |
| 605 | 605 | // Shorten colors from rgb(51,102,153) to #336699, rgb(100%,0%,0%) to #ff0000 (sRGB color space) |
| 606 | 606 | // Shorten colors from hsl(0, 100%, 50%) to #ff0000 (sRGB color space) |
| 607 | 607 | // This makes it more likely that it'll get further compressed in the next step. |
| 608 | + // Only the plain three-component form is converted (comma- or space-separated). | |
| 609 | + // Colors with an alpha channel, i.e. rgb(0, 0, 0, .5) and rgb(0 0 0 / 50%), are | |
| 610 | + // left alone just like rgba()/hsla(): a 6-digit hex cannot carry the alpha. | |
| 608 | 611 | $body = preg_replace_callback( |
| 609 | - '/(rgb|hsl)\(([0-9,.% -]+)\)(.|$)/Si', | |
| 612 | + '/(rgb|hsl)\(\s*(-?[0-9.]+%?)\s*[, ]\s*(-?[0-9.]+%?)\s*[, ]\s*(-?[0-9.]+%?)\s*\)(.|$)/Si', | |
| 610 | 613 | array($this, 'shortenHslAndRgbToHexCallback'), |
| 611 | 614 | $body |
| 612 | 615 | ); |
| 613 | 616 | |
| @@ -870,10 +873,10 @@ | ||
| 870 | 873 | */ |
| 871 | 874 | private function shortenHslAndRgbToHexCallback($matches) |
| 872 | 875 | { |
| 873 | 876 | $type = $matches[1]; |
| 874 | - $values = explode(',', $matches[2]); | |
| 875 | - $terminator = $matches[3]; | |
| 877 | + $values = array($matches[2], $matches[3], $matches[4]); | |
| 878 | + $terminator = $matches[5]; | |
| 876 | 879 | |
| 877 | 880 | if ($type === 'hsl') { |
| 878 | 881 | $values = Utils::hslToRgb($values); |
| 879 | 882 | } |