simonschaufi / cssmin

Automatically exported from code.google.com/p/cssmin
0 stars 0 forks source link

preserve-urls option doesn't retransform the urls correctly #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. use a url() expression in your css, say, a background style (ex.
background:url(sprite.png);
2. use the preserve-urls option
3. minify

What is the expected output? What do you see instead?
- Expected for background portion: background:url(sprite.png);
- Instead seeing: background:url(YzNCeWFYUmxMbkJ1Wnc9PQ==);

What version of the product are you using? On what operating system?
1.0.1.b3 (2008-10-02) on Windows and Linux

Please provide any additional information below.

FIX FOUND:
---------- 

The Problem:
------------
seems to be a typo - basically the cssmin process for preserving urls is to
base64_encode them, then perform minification, then base64_decode those
urls.  BUT, when it performs the decode step, it actually performs another
encode... the errant line of code in the version noted above is line 72:

$css = preg_replace_callback("/url\s*\((.*)\)/siU", "cssmin_encode_url", $css);

The Solution:
-------------
Line 72 should be: (notice the precise name of the callback function)

$css = preg_replace_callback("/url\s*\((.*)\)/siU", "cssmin_decode_url", $css);

That resolves the problem.

Original issue reported on code.google.com by jassem.s...@gmail.com on 13 May 2009 at 7:10

GoogleCodeExporter commented 9 years ago
Fixed in v2.0.0.b1

Original comment by joe.scylla on 6 Aug 2010 at 1:07