rusteerio 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +73 -0
- package/Cargo.lock +1051 -0
- package/Cargo.toml +36 -0
- package/LICENSE +21 -0
- package/README.md +252 -2
- package/RELEASING.md +138 -0
- package/THIRD_PARTY_NOTICES.md +7443 -0
- package/build.rs +3 -0
- package/dist/chunk-DKULX6VO.mjs +3185 -0
- package/dist/chunk-DKULX6VO.mjs.map +1 -0
- package/dist/chunk-OHPGEY3E.mjs +32 -0
- package/dist/chunk-OHPGEY3E.mjs.map +1 -0
- package/dist/index.cjs +3230 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +113 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.mjs +38 -0
- package/dist/index.mjs.map +1 -0
- package/dist/slim.cjs +2441 -0
- package/dist/slim.cjs.map +1 -0
- package/dist/slim.d.mts +11 -0
- package/dist/slim.d.ts +11 -0
- package/dist/slim.mjs +19 -0
- package/dist/slim.mjs.map +1 -0
- package/dist/types-BP6TpxE5.d.mts +532 -0
- package/dist/types-BP6TpxE5.d.ts +532 -0
- package/dist/utils.cjs +61 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.mts +13 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.mjs +17 -0
- package/dist/utils.mjs.map +1 -0
- package/native/src/arena.rs +1781 -0
- package/native/src/attributes.rs +923 -0
- package/native/src/codec.rs +172 -0
- package/native/src/diagnostics.rs +1249 -0
- package/native/src/extraction.rs +226 -0
- package/native/src/gc.rs +166 -0
- package/native/src/hook_sink.rs +727 -0
- package/native/src/hook_stream.rs +513 -0
- package/native/src/lib.rs +2095 -0
- package/native/src/location.rs +392 -0
- package/native/src/runtime.rs +189 -0
- package/native/src/selector.rs +1287 -0
- package/native/src/sink.rs +261 -0
- package/native/src/stream.rs +334 -0
- package/native/src/tokenizer.rs +355 -0
- package/native/src/tracker.rs +232 -0
- package/native/vendor/README.md +25 -0
- package/native/vendor/html5ever-0.35.0/.cargo_vcs_info.json +6 -0
- package/native/vendor/html5ever-0.35.0/Cargo.lock +828 -0
- package/native/vendor/html5ever-0.35.0/Cargo.toml +85 -0
- package/native/vendor/html5ever-0.35.0/LICENSE-APACHE +201 -0
- package/native/vendor/html5ever-0.35.0/LICENSE-MIT +25 -0
- package/native/vendor/html5ever-0.35.0/README.md +60 -0
- package/native/vendor/html5ever-0.35.0/benches/html5ever.rs +86 -0
- package/native/vendor/html5ever-0.35.0/data/bench/lipsum-zh.html +19 -0
- package/native/vendor/html5ever-0.35.0/data/bench/lipsum.html +40 -0
- package/native/vendor/html5ever-0.35.0/data/bench/medium-fragment.html +24 -0
- package/native/vendor/html5ever-0.35.0/data/bench/small-fragment.html +7 -0
- package/native/vendor/html5ever-0.35.0/data/bench/strong.html +1 -0
- package/native/vendor/html5ever-0.35.0/data/bench/tiny-fragment.html +1 -0
- package/native/vendor/html5ever-0.35.0/examples/arena.rs +356 -0
- package/native/vendor/html5ever-0.35.0/examples/capi/tokenize.c +74 -0
- package/native/vendor/html5ever-0.35.0/examples/noop-tokenize.rs +47 -0
- package/native/vendor/html5ever-0.35.0/examples/noop-tree-builder.rs +132 -0
- package/native/vendor/html5ever-0.35.0/examples/print-tree-actions.rs +185 -0
- package/native/vendor/html5ever-0.35.0/examples/tokenize.rs +111 -0
- package/native/vendor/html5ever-0.35.0/src/driver.rs +148 -0
- package/native/vendor/html5ever-0.35.0/src/lib.rs +30 -0
- package/native/vendor/html5ever-0.35.0/src/macros.rs +34 -0
- package/native/vendor/html5ever-0.35.0/src/serialize/mod.rs +255 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/char_ref/mod.rs +451 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/interface.rs +99 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/mod.rs +2305 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/states.rs +97 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/data.rs +170 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/mod.rs +1848 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/rules.rs +1494 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/tag_sets.rs +114 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/types.rs +91 -0
- package/native/vendor/html5ever-0.35.0/src/util/str.rs +52 -0
- package/native/vendor/html5gum-0.8.4/Cargo.lock +1006 -0
- package/native/vendor/html5gum-0.8.4/Cargo.toml +109 -0
- package/native/vendor/html5gum-0.8.4/LICENSE +19 -0
- package/native/vendor/html5gum-0.8.4/README.md +110 -0
- package/native/vendor/html5gum-0.8.4/benches/files/0050.html +2131 -0
- package/native/vendor/html5gum-0.8.4/benches/files/6D30.html +1004 -0
- package/native/vendor/html5gum-0.8.4/benches/files.rs +32 -0
- package/native/vendor/html5gum-0.8.4/benches/patterns.rs +31 -0
- package/native/vendor/html5gum-0.8.4/src/arrayvec.rs +29 -0
- package/native/vendor/html5gum-0.8.4/src/char_validator.rs +134 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/callback.rs +676 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/default.rs +207 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/emitter.rs +344 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/html5ever.rs +306 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/mod.rs +25 -0
- package/native/vendor/html5gum-0.8.4/src/entities.rs +3342 -0
- package/native/vendor/html5gum-0.8.4/src/error.rs +96 -0
- package/native/vendor/html5gum-0.8.4/src/htmlstring.rs +130 -0
- package/native/vendor/html5gum-0.8.4/src/lib.rs +66 -0
- package/native/vendor/html5gum-0.8.4/src/machine.rs +2136 -0
- package/native/vendor/html5gum-0.8.4/src/machine_helper.rs +277 -0
- package/native/vendor/html5gum-0.8.4/src/read_helper.rs +244 -0
- package/native/vendor/html5gum-0.8.4/src/reader.rs +440 -0
- package/native/vendor/html5gum-0.8.4/src/span.rs +98 -0
- package/native/vendor/html5gum-0.8.4/src/state.rs +16 -0
- package/native/vendor/html5gum-0.8.4/src/testutils.rs +71 -0
- package/native/vendor/html5gum-0.8.4/src/tokenizer.rs +189 -0
- package/native/vendor/html5gum-0.8.4/src/utils.rs +88 -0
- package/native/vendor/markup5ever-0.35.0/.cargo_vcs_info.json +6 -0
- package/native/vendor/markup5ever-0.35.0/Cargo.toml +45 -0
- package/native/vendor/markup5ever-0.35.0/LICENSE-APACHE +201 -0
- package/native/vendor/markup5ever-0.35.0/LICENSE-MIT +25 -0
- package/native/vendor/markup5ever-0.35.0/interface/mod.rs +422 -0
- package/native/vendor/markup5ever-0.35.0/interface/tree_builder.rs +280 -0
- package/native/vendor/markup5ever-0.35.0/lib.rs +59 -0
- package/native/vendor/markup5ever-0.35.0/serialize.rs +77 -0
- package/native/vendor/markup5ever-0.35.0/util/buffer_queue.rs +333 -0
- package/native/vendor/markup5ever-0.35.0/util/smallcharset.rs +88 -0
- package/package.json +137 -4
- package/rusteerio.darwin-arm64.node +0 -0
- package/rusteerio.darwin-x64.node +0 -0
- package/rusteerio.linux-arm64-gnu.node +0 -0
- package/rusteerio.linux-arm64-musl.node +0 -0
- package/rusteerio.linux-x64-gnu.node +0 -0
- package/rusteerio.linux-x64-musl.node +0 -0
- package/rusteerio.win32-arm64-msvc.node +0 -0
- package/rusteerio.win32-x64-msvc.node +0 -0
- package/scripts/check-native.mjs +15 -0
- package/scripts/check-release.mjs +235 -0
- package/scripts/fix-declarations.mjs +27 -0
- package/scripts/generate-notices.mjs +176 -0
- package/scripts/notices/README.md +13 -0
- package/scripts/notices/cheerio-MIT.txt +21 -0
- package/scripts/notices/html5ever-AUTHORS.txt +20 -0
- package/scripts/notices/html5ever-COPYRIGHT.txt +8 -0
- package/scripts/notices/html5ever-LICENSE-APACHE.txt +201 -0
- package/scripts/notices/html5ever-LICENSE-MIT.txt +25 -0
- package/scripts/notices/napi-rs-MIT.txt +43 -0
- package/scripts/notices/neon-MIT.txt +19 -0
- package/scripts/notices/runtime-01c266bced4a434da005.txt +3 -0
- package/scripts/notices/runtime-0a54e647fe54104658b5.txt +14 -0
- package/scripts/notices/runtime-0b74dfa0bcee5c420c6b.txt +25 -0
- package/scripts/notices/runtime-0d542e0c8804e39aa7f3.txt +177 -0
- package/scripts/notices/runtime-0f96a83840e146e43c0e.txt +21 -0
- package/scripts/notices/runtime-123a331b5dbf04c30097.txt +25 -0
- package/scripts/notices/runtime-172020dbfd5b53a226df.txt +34 -0
- package/scripts/notices/runtime-209fbbe0ad52d9235e37.txt +26 -0
- package/scripts/notices/runtime-23f18e03dc49df91622f.txt +23 -0
- package/scripts/notices/runtime-268872b9816f90fd8e85.txt +220 -0
- package/scripts/notices/runtime-35242e7a83f69875e6ed.txt +176 -0
- package/scripts/notices/runtime-378f5840b258e2779c39.txt +25 -0
- package/scripts/notices/runtime-4108245a1f2df9d4e94d.txt +25 -0
- package/scripts/notices/runtime-4455bf75a91154108304.txt +21 -0
- package/scripts/notices/runtime-553fffcd9b1cb158bc3e.txt +13 -0
- package/scripts/notices/runtime-62c7a1e35f56406896d7.txt +176 -0
- package/scripts/notices/runtime-6485b8ed310d3f0340bf.txt +25 -0
- package/scripts/notices/runtime-69fef7b0f322a6555415.txt +201 -0
- package/scripts/notices/runtime-6df43f6f4b5d4587f3d8.txt +187 -0
- package/scripts/notices/runtime-799e9ca9d179295ef372.txt +24 -0
- package/scripts/notices/runtime-7b63ecd5f1902af1b637.txt +25 -0
- package/scripts/notices/runtime-7bc7d5de2a0b793d4e1a.txt +21 -0
- package/scripts/notices/runtime-7e12e5df4bae12cb2158.txt +24 -0
- package/scripts/notices/runtime-861399f8c21c042b1105.txt +12 -0
- package/scripts/notices/runtime-8ada45cd9f843acf64e4.txt +201 -0
- package/scripts/notices/runtime-90eb64f0279b0d9432ac.txt +12 -0
- package/scripts/notices/runtime-a60eea817514531668d7.txt +201 -0
- package/scripts/notices/runtime-a7c936ff1ed8fa340172.txt +25 -0
- package/scripts/notices/runtime-ab6eec6caf0fa5775e41.txt +275 -0
- package/scripts/notices/runtime-b1181a40b2a7b25cf66f.txt +19 -0
- package/scripts/notices/runtime-b71bd43a069ca0641a9e.txt +25 -0
- package/scripts/notices/runtime-c16f8dcf1a368b83be78.txt +201 -0
- package/scripts/notices/runtime-c2cfccb812fe482101a8.txt +21 -0
- package/scripts/notices/runtime-e99d88d232bf57d70f0f.txt +25 -0
- package/scripts/notices/runtime-f32fb3b417a194167cfa.txt +9 -0
- package/scripts/notices/runtime-f5062c9a188d81dfe66b.txt +39 -0
- package/scripts/notices/runtime-f9070a832833fa7488fd.txt +4 -0
- package/scripts/notices/runtime-fab3dd6bdab226f1c086.txt +373 -0
- package/scripts/notices/runtime-fba3318d0c600380177e.txt +62 -0
- package/scripts/notices/runtime-ff8f68cb076caf8cefe7.txt +25 -0
- package/scripts/notices/runtime-ff92bed461f50338dd70.txt +74 -0
- package/scripts/notices/runtime.json +1632 -0
- package/scripts/notices/sources.json +555 -0
- package/scripts/notices/xray-MIT.txt +21 -0
- package/src/attributes.ts +271 -0
- package/src/codec.ts +74 -0
- package/src/dom.ts +87 -0
- package/src/extract-plan.ts +97 -0
- package/src/extract.ts +130 -0
- package/src/hooks.ts +220 -0
- package/src/index.ts +223 -0
- package/src/io.ts +491 -0
- package/src/native.ts +135 -0
- package/src/nodes.ts +290 -0
- package/src/parse.ts +53 -0
- package/src/parser-types.ts +157 -0
- package/src/router.ts +327 -0
- package/src/selection.ts +566 -0
- package/src/slim.ts +12 -0
- package/src/transport.ts +104 -0
- package/src/types.ts +186 -0
- package/src/utils.ts +29 -0
- package/src/workers.ts +21 -0
- package/tsconfig.json +15 -0
- package/tsup.config.ts +16 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Copyright 2014-2017 The html5ever Project Developers. See the
|
|
2
|
+
// COPYRIGHT file at the top-level directory of this distribution.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
5
|
+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
6
|
+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
7
|
+
// option. This file may not be copied, modified, or distributed
|
|
8
|
+
// except according to those terms.
|
|
9
|
+
|
|
10
|
+
//! Tokenizer states.
|
|
11
|
+
//!
|
|
12
|
+
//! This is public for use by the tokenizer tests. Other library
|
|
13
|
+
//! users should not have to care about this.
|
|
14
|
+
|
|
15
|
+
pub use self::AttrValueKind::*;
|
|
16
|
+
pub use self::DoctypeIdKind::*;
|
|
17
|
+
pub use self::RawKind::*;
|
|
18
|
+
pub use self::ScriptEscapeKind::*;
|
|
19
|
+
pub use self::State::*;
|
|
20
|
+
|
|
21
|
+
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash, Debug)]
|
|
22
|
+
pub enum ScriptEscapeKind {
|
|
23
|
+
Escaped,
|
|
24
|
+
DoubleEscaped,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash, Debug)]
|
|
28
|
+
pub enum DoctypeIdKind {
|
|
29
|
+
Public,
|
|
30
|
+
System,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash, Debug)]
|
|
34
|
+
pub enum RawKind {
|
|
35
|
+
Rcdata,
|
|
36
|
+
Rawtext,
|
|
37
|
+
ScriptData,
|
|
38
|
+
ScriptDataEscaped(ScriptEscapeKind),
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash, Debug)]
|
|
42
|
+
pub enum AttrValueKind {
|
|
43
|
+
Unquoted,
|
|
44
|
+
SingleQuoted,
|
|
45
|
+
DoubleQuoted,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash, Debug)]
|
|
49
|
+
pub enum State {
|
|
50
|
+
Data,
|
|
51
|
+
Plaintext,
|
|
52
|
+
TagOpen,
|
|
53
|
+
EndTagOpen,
|
|
54
|
+
TagName,
|
|
55
|
+
RawData(RawKind),
|
|
56
|
+
RawLessThanSign(RawKind),
|
|
57
|
+
RawEndTagOpen(RawKind),
|
|
58
|
+
RawEndTagName(RawKind),
|
|
59
|
+
ScriptDataEscapeStart(ScriptEscapeKind),
|
|
60
|
+
ScriptDataEscapeStartDash,
|
|
61
|
+
ScriptDataEscapedDash(ScriptEscapeKind),
|
|
62
|
+
ScriptDataEscapedDashDash(ScriptEscapeKind),
|
|
63
|
+
ScriptDataDoubleEscapeEnd,
|
|
64
|
+
BeforeAttributeName,
|
|
65
|
+
AttributeName,
|
|
66
|
+
AfterAttributeName,
|
|
67
|
+
BeforeAttributeValue,
|
|
68
|
+
AttributeValue(AttrValueKind),
|
|
69
|
+
AfterAttributeValueQuoted,
|
|
70
|
+
SelfClosingStartTag,
|
|
71
|
+
BogusComment,
|
|
72
|
+
MarkupDeclarationOpen,
|
|
73
|
+
CommentStart,
|
|
74
|
+
CommentStartDash,
|
|
75
|
+
Comment,
|
|
76
|
+
CommentLessThanSign,
|
|
77
|
+
CommentLessThanSignBang,
|
|
78
|
+
CommentLessThanSignBangDash,
|
|
79
|
+
CommentLessThanSignBangDashDash,
|
|
80
|
+
CommentEndDash,
|
|
81
|
+
CommentEnd,
|
|
82
|
+
CommentEndBang,
|
|
83
|
+
Doctype,
|
|
84
|
+
BeforeDoctypeName,
|
|
85
|
+
DoctypeName,
|
|
86
|
+
AfterDoctypeName,
|
|
87
|
+
AfterDoctypeKeyword(DoctypeIdKind),
|
|
88
|
+
BeforeDoctypeIdentifier(DoctypeIdKind),
|
|
89
|
+
DoctypeIdentifierDoubleQuoted(DoctypeIdKind),
|
|
90
|
+
DoctypeIdentifierSingleQuoted(DoctypeIdKind),
|
|
91
|
+
AfterDoctypeIdentifier(DoctypeIdKind),
|
|
92
|
+
BetweenDoctypePublicAndSystemIdentifiers,
|
|
93
|
+
BogusDoctype,
|
|
94
|
+
CdataSection,
|
|
95
|
+
CdataSectionBracket,
|
|
96
|
+
CdataSectionEnd,
|
|
97
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// Copyright 2014-2017 The html5ever Project Developers. See the
|
|
2
|
+
// COPYRIGHT file at the top-level directory of this distribution.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
5
|
+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
6
|
+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
7
|
+
// option. This file may not be copied, modified, or distributed
|
|
8
|
+
// except according to those terms.
|
|
9
|
+
|
|
10
|
+
use crate::interface::{LimitedQuirks, NoQuirks, Quirks, QuirksMode};
|
|
11
|
+
use crate::tendril::StrTendril;
|
|
12
|
+
use crate::tokenizer::Doctype;
|
|
13
|
+
|
|
14
|
+
// These should all be lowercase, for ASCII-case-insensitive matching.
|
|
15
|
+
static QUIRKY_PUBLIC_PREFIXES: &[&str] = &[
|
|
16
|
+
"-//advasoft ltd//dtd html 3.0 aswedit + extensions//",
|
|
17
|
+
"-//as//dtd html 3.0 aswedit + extensions//",
|
|
18
|
+
"-//ietf//dtd html 2.0 level 1//",
|
|
19
|
+
"-//ietf//dtd html 2.0 level 2//",
|
|
20
|
+
"-//ietf//dtd html 2.0 strict level 1//",
|
|
21
|
+
"-//ietf//dtd html 2.0 strict level 2//",
|
|
22
|
+
"-//ietf//dtd html 2.0 strict//",
|
|
23
|
+
"-//ietf//dtd html 2.0//",
|
|
24
|
+
"-//ietf//dtd html 2.1e//",
|
|
25
|
+
"-//ietf//dtd html 3.0//",
|
|
26
|
+
"-//ietf//dtd html 3.2 final//",
|
|
27
|
+
"-//ietf//dtd html 3.2//",
|
|
28
|
+
"-//ietf//dtd html 3//",
|
|
29
|
+
"-//ietf//dtd html level 0//",
|
|
30
|
+
"-//ietf//dtd html level 1//",
|
|
31
|
+
"-//ietf//dtd html level 2//",
|
|
32
|
+
"-//ietf//dtd html level 3//",
|
|
33
|
+
"-//ietf//dtd html strict level 0//",
|
|
34
|
+
"-//ietf//dtd html strict level 1//",
|
|
35
|
+
"-//ietf//dtd html strict level 2//",
|
|
36
|
+
"-//ietf//dtd html strict level 3//",
|
|
37
|
+
"-//ietf//dtd html strict//",
|
|
38
|
+
"-//ietf//dtd html//",
|
|
39
|
+
"-//metrius//dtd metrius presentational//",
|
|
40
|
+
"-//microsoft//dtd internet explorer 2.0 html strict//",
|
|
41
|
+
"-//microsoft//dtd internet explorer 2.0 html//",
|
|
42
|
+
"-//microsoft//dtd internet explorer 2.0 tables//",
|
|
43
|
+
"-//microsoft//dtd internet explorer 3.0 html strict//",
|
|
44
|
+
"-//microsoft//dtd internet explorer 3.0 html//",
|
|
45
|
+
"-//microsoft//dtd internet explorer 3.0 tables//",
|
|
46
|
+
"-//netscape comm. corp.//dtd html//",
|
|
47
|
+
"-//netscape comm. corp.//dtd strict html//",
|
|
48
|
+
"-//o'reilly and associates//dtd html 2.0//",
|
|
49
|
+
"-//o'reilly and associates//dtd html extended 1.0//",
|
|
50
|
+
"-//o'reilly and associates//dtd html extended relaxed 1.0//",
|
|
51
|
+
"-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//",
|
|
52
|
+
"-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//",
|
|
53
|
+
"-//spyglass//dtd html 2.0 extended//",
|
|
54
|
+
"-//sq//dtd html 2.0 hotmetal + extensions//",
|
|
55
|
+
"-//sun microsystems corp.//dtd hotjava html//",
|
|
56
|
+
"-//sun microsystems corp.//dtd hotjava strict html//",
|
|
57
|
+
"-//w3c//dtd html 3 1995-03-24//",
|
|
58
|
+
"-//w3c//dtd html 3.2 draft//",
|
|
59
|
+
"-//w3c//dtd html 3.2 final//",
|
|
60
|
+
"-//w3c//dtd html 3.2//",
|
|
61
|
+
"-//w3c//dtd html 3.2s draft//",
|
|
62
|
+
"-//w3c//dtd html 4.0 frameset//",
|
|
63
|
+
"-//w3c//dtd html 4.0 transitional//",
|
|
64
|
+
"-//w3c//dtd html experimental 19960712//",
|
|
65
|
+
"-//w3c//dtd html experimental 970421//",
|
|
66
|
+
"-//w3c//dtd w3 html//",
|
|
67
|
+
"-//w3o//dtd w3 html 3.0//",
|
|
68
|
+
"-//webtechs//dtd mozilla html 2.0//",
|
|
69
|
+
"-//webtechs//dtd mozilla html//",
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
static QUIRKY_PUBLIC_MATCHES: &[&str] = &[
|
|
73
|
+
"-//w3o//dtd w3 html strict 3.0//en//",
|
|
74
|
+
"-/w3c/dtd html 4.0 transitional/en",
|
|
75
|
+
"html",
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
static QUIRKY_SYSTEM_MATCHES: &[&str] =
|
|
79
|
+
&["http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"];
|
|
80
|
+
|
|
81
|
+
static LIMITED_QUIRKY_PUBLIC_PREFIXES: &[&str] = &[
|
|
82
|
+
"-//w3c//dtd xhtml 1.0 frameset//",
|
|
83
|
+
"-//w3c//dtd xhtml 1.0 transitional//",
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
static HTML4_PUBLIC_PREFIXES: &[&str] = &[
|
|
87
|
+
"-//w3c//dtd html 4.01 frameset//",
|
|
88
|
+
"-//w3c//dtd html 4.01 transitional//",
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
pub(crate) fn doctype_error_and_quirks(
|
|
92
|
+
doctype: &Doctype,
|
|
93
|
+
iframe_srcdoc: bool,
|
|
94
|
+
) -> (bool, QuirksMode) {
|
|
95
|
+
fn opt_string_as_slice(x: &Option<String>) -> Option<&str> {
|
|
96
|
+
x.as_deref()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
fn opt_tendril_as_slice(x: &Option<StrTendril>) -> Option<&str> {
|
|
100
|
+
x.as_deref()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
fn opt_to_ascii_lower(x: Option<&str>) -> Option<String> {
|
|
104
|
+
x.map(|y| y.to_ascii_lowercase())
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let name = opt_tendril_as_slice(&doctype.name);
|
|
108
|
+
let public = opt_tendril_as_slice(&doctype.public_id);
|
|
109
|
+
let system = opt_tendril_as_slice(&doctype.system_id);
|
|
110
|
+
|
|
111
|
+
let err = !matches!(
|
|
112
|
+
(name, public, system),
|
|
113
|
+
(Some("html"), None, None)
|
|
114
|
+
| (Some("html"), None, Some("about:legacy-compat"))
|
|
115
|
+
| (Some("html"), Some("-//W3C//DTD HTML 4.0//EN"), None)
|
|
116
|
+
| (
|
|
117
|
+
Some("html"),
|
|
118
|
+
Some("-//W3C//DTD HTML 4.0//EN"),
|
|
119
|
+
Some("http://www.w3.org/TR/REC-html40/strict.dtd"),
|
|
120
|
+
)
|
|
121
|
+
| (Some("html"), Some("-//W3C//DTD HTML 4.01//EN"), None)
|
|
122
|
+
| (
|
|
123
|
+
Some("html"),
|
|
124
|
+
Some("-//W3C//DTD HTML 4.01//EN"),
|
|
125
|
+
Some("http://www.w3.org/TR/html4/strict.dtd"),
|
|
126
|
+
)
|
|
127
|
+
| (
|
|
128
|
+
Some("html"),
|
|
129
|
+
Some("-//W3C//DTD XHTML 1.0 Strict//EN"),
|
|
130
|
+
Some("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"),
|
|
131
|
+
)
|
|
132
|
+
| (
|
|
133
|
+
Some("html"),
|
|
134
|
+
Some("-//W3C//DTD XHTML 1.1//EN"),
|
|
135
|
+
Some("http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"),
|
|
136
|
+
)
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
// FIXME: We could do something asymptotically faster here.
|
|
140
|
+
// But there aren't many strings, and this happens at most once per parse.
|
|
141
|
+
fn contains_pfx(haystack: &[&str], needle: &str) -> bool {
|
|
142
|
+
haystack.iter().any(|&x| needle.starts_with(x))
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Quirks-mode matches are case-insensitive.
|
|
146
|
+
let public = opt_to_ascii_lower(public);
|
|
147
|
+
let system = opt_to_ascii_lower(system);
|
|
148
|
+
|
|
149
|
+
let quirk = match (opt_string_as_slice(&public), opt_string_as_slice(&system)) {
|
|
150
|
+
_ if doctype.force_quirks => Quirks,
|
|
151
|
+
_ if name != Some("html") => Quirks,
|
|
152
|
+
|
|
153
|
+
_ if iframe_srcdoc => NoQuirks,
|
|
154
|
+
|
|
155
|
+
(Some(ref p), _) if QUIRKY_PUBLIC_MATCHES.contains(p) => Quirks,
|
|
156
|
+
(_, Some(ref s)) if QUIRKY_SYSTEM_MATCHES.contains(s) => Quirks,
|
|
157
|
+
|
|
158
|
+
(Some(p), _) if contains_pfx(QUIRKY_PUBLIC_PREFIXES, p) => Quirks,
|
|
159
|
+
(Some(p), _) if contains_pfx(LIMITED_QUIRKY_PUBLIC_PREFIXES, p) => LimitedQuirks,
|
|
160
|
+
|
|
161
|
+
(Some(p), s) if contains_pfx(HTML4_PUBLIC_PREFIXES, p) => match s {
|
|
162
|
+
None => Quirks,
|
|
163
|
+
Some(_) => LimitedQuirks,
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
_ => NoQuirks,
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
(err, quirk)
|
|
170
|
+
}
|