Skip to content

Commit 40d49d5

Browse files
author
bors-servo
committed
Auto merge of #199 - servo:prescan, r=SimonSapin
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. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/html5ever/199) <!-- Reviewable:end -->
2 parents 6b55e4b + 199a84a commit 40d49d5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "html5ever"
4-
version = "0.5.2"
4+
version = "0.5.3"
55
authors = [ "The html5ever Project Developers" ]
66
license = "MIT / Apache-2.0"
77
repository = "https://github.com/servo/html5ever"

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)