lemankk / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

large image in base64 - CSS - Fatal error #300

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Minify commit/version: 2.1.7
PHP version: 5.3.27

What steps will reproduce the problem?
1. encode a large image in base64 and paste in CSS
(кодируем большую картинку в base64 и 
вставляем в CSS)
2. Minify
3. "Fatal error: Maximum execution time of 30 seconds exceeded"

Expected output:
the script should not get hung up on base64 images/data
(скрипт не должен зацикливаться на base64 
изображениях)

Actual output:
script hangs in an endless loop on the base64 images/data
(скрипт виснет в бесконечном цикле над base64 
данными)

Original issue reported on code.google.com by ad...@g63.ru on 5 Nov 2013 at 12:17

Attachments:

GoogleCodeExporter commented 9 years ago
Please try the CSSMin configuration:
http://code.google.com/p/minify/wiki/CookBook#CSSmin_PHP_port

Original comment by mrclay....@gmail.com on 5 Nov 2013 at 3:29

GoogleCodeExporter commented 9 years ago
I can not understand how to use this code. I put it in /min/config.php, but 
that does not change (not work)
(Я не могу понять как пользоваться данным 
кодом. Я вставил его в /min/config.php, но ни чего 
не изменилось)

I found another version of the solutions (not ideal)
Я нашел другой вариант решения (не 
идеальный)

This problem in the file /min/lib/Minify/CSS/Compressor.php #113-124

// remove ws in selectors
$css = preg_replace_callback('/
        (?:              # non-capture
            \\s*
            [^~>+,\\s]+  # selector part
            \\s*
            [,>+~]       # combinators
        )+
        \\s*
        [^~>+,\\s]+      # selector part
        {                # open declaration block
    /x'
    ,array($this, '_selectorsCB'), $css);

a temporary solution to this problem
(временное решение этой проблемы)

preg_match_all('~(url\((\'|")data:image/(jpeg|gif|png|svg)(.*)(\'|")\))~', 
$css, $temp_base64, PREG_PATTERN_ORDER);
$css = preg_replace('~(url\((\'|")data:image/(jpeg|gif|png|svg)(.*)(\'|")\))~', 
'temp_base64_c7dc78yhuinm4', $css);

// remove ws in selectors
$css = preg_replace_callback('/
        (?:              # non-capture
            \\s*
            [^~>+,\\s]+  # selector part
            \\s*
            [,>+~]       # combinators
        )+
        \\s*
        [^~>+,\\s]+      # selector part
        {                # open declaration block
    /x'
    ,array($this, '_selectorsCB'), $css);

$i = 0;
foreach ($temp_base64[0] as $return_from_temp) {
    $css = preg_replace('~temp_base64_c7dc78yhuinm4~', $return_from_temp, $css, ++$i);
}

Original comment by ad...@g63.ru on 5 Nov 2013 at 4:33

GoogleCodeExporter commented 9 years ago
Paste the code from the wiki (http://pastebin.com/GLd0a1cn) into min/config.php 
and clear your browser cache. CSSmin will be used for compression and it has 
specific workarounds for this issue. I have no time/interest in patching the 
Minify_CSS_Compressor class at this time.

Original comment by mrclay....@gmail.com on 5 Nov 2013 at 1:49

GoogleCodeExporter commented 9 years ago
Ok. Thank you for your help.

Original comment by ad...@g63.ru on 5 Nov 2013 at 5:13