Skip to content

Limit the encoding detection to 3 bytes for now. #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "html5ever"
version = "0.5.2"
version = "0.5.3"
authors = [ "The html5ever Project Developers" ]
license = "MIT / Apache-2.0"
repository = "https://github.com/servo/html5ever"
Expand Down
6 changes: 3 additions & 3 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ impl<Sink: TreeSink> TendrilSink<tendril::fmt::Bytes> for BytesParser<Sink> {
}

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

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

Expand Down