Skip to content

Commit b330e64

Browse files
committed
[css-syntax] Limit @charset to 1024 bytes, like <meta charset> in HTML.
1 parent b91324a commit b330e64

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

css-syntax/Overview.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</p>
5555
<h1 class="p-name no-ref" id=title>CSS Syntax Module Level 3</h1>
5656
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
57-
<span class=dt-updated><span class=value-title title=20140124>24 January 2014</span></span></span></h2>
57+
<span class=dt-updated><span class=value-title title=20140127>27 January 2014</span></span></span></h2>
5858
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-syntax/>http://dev.w3.org/csswg/css-syntax/</a><dt>Latest version:<dd><a href=http://www.w3.org/TR/css-syntax-3/>http://www.w3.org/TR/css-syntax-3/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-syntax/>http://dev.w3.org/csswg/css-syntax/</a><dt>Previous Versions:<dd><a href=http://www.w3.org/TR/2013/WD-css-syntax-3-20131105/ rel=previous>http://www.w3.org/TR/2013/WD-css-syntax-3-20131105/</a><dd><a href=http://www.w3.org/TR/2013/WD-css-syntax-3-20130919/ rel=previous>http://www.w3.org/TR/2013/WD-css-syntax-3-20130919/</a>
5959
<dt>Feedback:</dt>
6060
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-syntax%5D%20feedback">www-style@w3.org</a>
@@ -446,7 +446,8 @@ <h3 class="heading settled heading" data-level=3.2 id=input-byte-stream><span cl
446446
use the return value as the fallback encoding.
447447

448448
<li>
449-
Otherwise, check the byte stream. If the byte stream begins with the hex sequence
449+
Otherwise, check the byte stream.
450+
If the first 1024 bytes of the stream begin with the hex sequence
450451

451452
<pre>40 63 68 61 72 73 65 74 20 22 XX* 22 3B</pre>
452453
<p> where each <code>XX</code> byte is between 23<sub>16</sub> and 7E<sub>16</sub> inclusive,
@@ -4704,7 +4705,15 @@ <h3 class="heading settled heading" data-level=10.1 id=changes-WD-20131105><span
47044705
<a data-biblio-type=informative data-link-type=biblio href=#encoding title=encoding>[ENCODING]</a> has been added to the list of normative references.
47054706
It was already referenced in normative text before,
47064707
just not listed as such.
4707-
</ul>
4708+
<li>
4709+
In the algorithm to <a data-link-type=dfn href=#determine-the-fallback-encoding title="determine the fallback encoding">determine the fallback encoding</a> of a stylesheet,
4710+
limit the <code>@charset</code> byte sequence to 1024 bytes.
4711+
This aligns with what HTML does for <code>&lt;meta charset&gt;</code>
4712+
and makes sure the size of the sequence is bounded.
4713+
This only makes a difference with leading or trailing whitespace
4714+
in the encoding label:
4715+
4716+
<pre>@charset " <em>(lots of whitespace)</em> utf-8";</pre> </ul>
47084717

47094718
<h3 class="heading settled heading" data-level=10.2 id=changes-WD-20130919><span class=secno>10.2 </span><span class=content>
47104719
Changes from the 19 September 2013 Working Draft</span><a class=self-link href=#changes-WD-20130919></a></h3>

css-syntax/Overview.src.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ <h3 id="input-byte-stream">
283283
use the return value as the fallback encoding.
284284

285285
<li>
286-
Otherwise, check the byte stream. If the byte stream begins with the hex sequence
286+
Otherwise, check the byte stream.
287+
If the first 1024 bytes of the stream begin with the hex sequence
287288

288289
<pre>40 63 68 61 72 73 65 74 20 22 XX* 22 3B</pre>
289290

@@ -3228,6 +3229,15 @@ <h3 id="changes-WD-20131105">
32283229
[[ENCODING]] has been added to the list of normative references.
32293230
It was already referenced in normative text before,
32303231
just not listed as such.
3232+
<li>
3233+
In the algorithm to <a>determine the fallback encoding</a> of a stylesheet,
3234+
limit the <code>@charset</code> byte sequence to 1024 bytes.
3235+
This aligns with what HTML does for <code>&lt;meta charset></code>
3236+
and makes sure the size of the sequence is bounded.
3237+
This only makes a difference with leading or trailing whitespace
3238+
in the encoding label:
3239+
3240+
<pre>@charset " <em>(lots of whitespace)</em> utf-8";</pre>
32313241
</ul>
32323242

32333243
<h3 id="changes-WD-20130919">

0 commit comments

Comments
 (0)