jianlinwei / cssmin

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

Inline Base64 images fail loading #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of CssMin are you using (source and/or build)?
v 2.0.2.2

What was the input stylesheet and/or configuration options?
  background-image:url('data:image/jpeg;base64,/9j/......//2Q%3D%3D')!important;

What is the expected result?
  background-image:url(data:image/jpeg;base64,/9j/4AAQ......//2Q%3D%3D)!important;

And what is the actual result and/or error message?
  background-image:url(/data:image/jpeg;base64,/9j/4AAQ......//2Q%3D%3D)!important;

Please provide any additional information below.
Adding the "/" before data alters the URL and causes embed base 64 encoded 
files to fail loading.

Original issue reported on code.google.com by jonathan...@gmail.com on 9 Apr 2011 at 10:46

GoogleCodeExporter commented 9 years ago
Thanks for reporting this issue.

Original comment by joe.scylla on 11 Apr 2011 at 1:17

GoogleCodeExporter commented 9 years ago
Hello,

when are you planning to fix this this issue? I looked at your code in an 
attempt to fix this, but it doesn't seem to be that simple :-)

It's probably somewhere around line 1170 isn't it?
 /**
         * Start of url string property
         */ elseif ($c == "(" && ($currentState != self::T_COMMENT && $currentState != self::T_STRING && $currentState != self::T_STRING_EXPRESSION) && strtolower(substr($css, $i - 3, 3) == "url")
                && ($currentState == self::T_DECLARATION || $currentState == self::T_FONT_FACE_DECLARATION || $currentState == self::T_PAGE_DECLARATION || $currentState == self::T_VARIABLE_DECLARATION || $currentState == self::T_AT_IMPORT)) {
          array_push($state, self::T_STRING_URL);

Original comment by jonathan...@gmail.com on 18 Jun 2011 at 8:39

GoogleCodeExporter commented 9 years ago
Unfortunately I'm very busy at the moment and i'm still undecided if i will fix 
that bug in version 2. First the implementation of this bugfix is going to be 
quite difficult because of the architecture of version 2 and at second version 
3 should have no problems with such data urls. Di you tried out version 3?

Original comment by joe.scylla on 20 Jun 2011 at 1:17

GoogleCodeExporter commented 9 years ago
Hello, I've just tried version 3 and the result is the same. (the minifier code 
looks better though).

Original comment by jonathan...@gmail.com on 23 Jun 2011 at 6:57

GoogleCodeExporter commented 9 years ago
Can you please attach here the complete ruleset? I would like to test it with 
version 3 because in version 3 data-url should get parsed correctly.

Original comment by joe.scylla on 24 Jun 2011 at 9:00

GoogleCodeExporter commented 9 years ago
Sorry for the late reply.
this are the parameters I'm using, I kept the same as for V2:

$optimizedContent = cssmin::minify(file_get_contents($file),
            array("convert-css3-properties" => true,
                  "compress-unit-values" => true,
                  "import-imports" => true,
                  "import-base-path" => $path,
                  "import-remove-invalid" => true));

Regarding the CSSmin lib, I haven't modified anything.

And this is the CSS extract:
"background-image:url('data:image/jpeg;base64,/9j/4AAQSkZJR...".

Thanks for your work, expect this error, I haven't found any.

Original comment by jonathan...@gmail.com on 7 Jul 2011 at 2:46

GoogleCodeExporter commented 9 years ago
My mistake, I was using the filters from V2, I didn't notice V3 introduced that 
change. You can close the issue.

Original comment by jonathan...@gmail.com on 10 Jul 2011 at 3:16

GoogleCodeExporter commented 9 years ago
ok no problem ;)

Original comment by joe.scylla on 13 Jul 2011 at 6:47