Skip to content

Commit 28d2b5b

Browse files
committed
Limit the encoding detection to 3 bytes for now.
This is intended to avoid issues when there's a parser-blocking script in the first 1024 bytes. See also #198.
1 parent 6b55e4b commit 28d2b5b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ impl<Sink: TreeSink> TendrilSink<tendril::fmt::Bytes> for BytesParser<Sink> {
264264
}
265265

266266
/// How many bytes does detect_encoding() need
267-
// NOTE: 3 would be enough for a BOM, but 1024 is specified for <meta> elements.
268-
const PRESCAN_BYTES: u32 = 1024;
267+
// FIXME(#18): should be 1024 for <meta> elements.
268+
const PRESCAN_BYTES: u32 = 3;
269269

270270
/// https://html.spec.whatwg.org/multipage/syntax.html#determining-the-character-encoding
271271
fn detect_encoding(bytes: &ByteTendril, opts: &BytesOpts) -> EncodingRef {
@@ -281,7 +281,7 @@ fn detect_encoding(bytes: &ByteTendril, opts: &BytesOpts) -> EncodingRef {
281281
if let Some(encoding) = opts.transport_layer_encoding {
282282
return encoding
283283
}
284-
// FIXME: <meta> etc.
284+
// FIXME(#18): <meta> etc.
285285
return encoding::all::UTF_8
286286
}
287287

0 commit comments

Comments
 (0)