ericmckean / minify

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

CSS @charset declaration mangled #106

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Minify version: 2.1.2
PHP version: 5.2.6

What steps will reproduce the problem?
1. Minify a CSS Stylesheet with a @charset declaration in the first line
2.
3.

Expected output: @charset rests in the first line, the other CSS
declarations get minified from the second line on

Actual output: @charset gets minified with the other declarations. The
@charset declaration gets invalid and is ignored by the browsers.

Did any unit tests FAIL? (Please do not post the full list)
!WARN: environment : Local HTTP request failed. Testing cannot continue.

Original issue reported on code.google.com by p.jer...@gmail.com on 21 Apr 2009 at 11:34

GoogleCodeExporter commented 9 years ago
What charset did you use and how was it mangled? Actual input/output of the 
first 
few lines would be handy.

Be aware that Minify automatically sets charset in the Content-Type header 
(UTF-8 by 
default). To change this, add one of these to config.php:
$min_serveOptions['contentTypeCharset'] = 'ISO-8859-1';
$min_serveOptions['contentTypeCharset'] = false; // do not set charset

Also note you must ensure all combined file have the same (or "compatible") 
encoding; they will not be normalized.

Original comment by mrclay....@gmail.com on 22 Apr 2009 at 5:25

GoogleCodeExporter commented 9 years ago
What charset did you use and how was it mangled?

>> I use UTF-8, as you can see in the following snippet:

>> @charset "UTF-8";@media screen,projection{body{background:#4d87c7 url
>> ("/css/images/bg_blue.png") repeat-x top left fixed;padding:10px
>> 0}#page_margins{margin:0

>> The problem is, that all CSS validators criticise that the @charset 
declaration 
>> should stand ALONE in the FIRST LINE.

Also note you must ensure all combined file have the same (or "compatible") 
encoding; they will not be normalized.

>> They have...

>> Maybe I should remove EVERY @charset declaration in my CSS files?

Original comment by p.jer...@gmail.com on 24 Apr 2009 at 9:39

GoogleCodeExporter commented 9 years ago
Since UTF-8 is the default, yes, you can remove all your @charset declarations. 
Also 
in CSS2.1, UTF-8 is assumed.

Looking into this more, a trailing newline is not required or even suggested by 
the 
current spec: http://www.w3.org/TR/CSS21/syndata.html#x50
...nor by its likely replacement: http://www.w3.org/TR/css3-syntax/#charset

Indeed the official validator does not complain:
http://jigsaw.w3.org/css-validator/#validate_by_input
This is completely valid:
@charset "UTF-8";body{background:#4d87c7;}

Thanks for taking the time to report this.

Original comment by mrclay....@gmail.com on 24 Apr 2009 at 1:17

GoogleCodeExporter commented 9 years ago
Issue 172 has been merged into this issue.

Original comment by mrclay....@gmail.com on 18 Apr 2010 at 10:47