cloudstructs 0.9.19 → 0.9.21
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/.jsii +4 -4
- package/assets/slack-textract/detect.lambda/index.js +21 -10
- package/lib/codecommit-mirror/index.js +2 -2
- package/lib/dmarc/index.js +1 -1
- package/lib/ecs-service-roller/index.js +2 -2
- package/lib/email-receiver/receiver.js +1 -1
- package/lib/mjml-template/index.js +1 -1
- package/lib/saml-identity-provider/index.js +2 -2
- package/lib/slack-app/manifest.js +1 -1
- package/lib/slack-app/slack-app.js +2 -2
- package/lib/slack-events/index.js +1 -1
- package/lib/slack-textract/index.js +1 -1
- package/lib/ssl-server-test/index.js +1 -1
- package/lib/state-machine-cr-provider/index.js +1 -1
- package/lib/static-website/index.js +1 -1
- package/lib/toolkit-cleaner/index.js +1 -1
- package/lib/url-shortener/index.js +1 -1
- package/node_modules/@babel/runtime/helpers/esm/superPropGet.js +4 -4
- package/node_modules/@babel/runtime/helpers/esm/superPropSet.js +2 -2
- package/node_modules/@babel/runtime/helpers/superPropGet.js +4 -4
- package/node_modules/@babel/runtime/helpers/superPropSet.js +2 -2
- package/node_modules/@babel/runtime/package.json +1 -1
- package/node_modules/@slack/logger/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/logger/node_modules/@types/node/assert.d.ts +2 -2
- package/node_modules/@slack/logger/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/node_modules/@slack/logger/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@slack/logger/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
- package/node_modules/@slack/logger/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/node_modules/@slack/logger/node_modules/@types/node/crypto.d.ts +10 -9
- package/node_modules/@slack/logger/node_modules/@types/node/events.d.ts +2 -2
- package/node_modules/@slack/logger/node_modules/@types/node/fs/promises.d.ts +15 -4
- package/node_modules/@slack/logger/node_modules/@types/node/fs.d.ts +1 -1
- package/node_modules/@slack/logger/node_modules/@types/node/globals.d.ts +17 -48
- package/node_modules/@slack/logger/node_modules/@types/node/http.d.ts +37 -0
- package/node_modules/@slack/logger/node_modules/@types/node/index.d.ts +8 -10
- package/node_modules/@slack/logger/node_modules/@types/node/module.d.ts +91 -0
- package/node_modules/@slack/logger/node_modules/@types/node/package.json +4 -3
- package/node_modules/@slack/logger/node_modules/@types/node/perf_hooks.d.ts +24 -0
- package/node_modules/@slack/logger/node_modules/@types/node/readline/promises.d.ts +14 -2
- package/node_modules/@slack/logger/node_modules/@types/node/readline.d.ts +58 -9
- package/node_modules/@slack/logger/node_modules/@types/node/stream/promises.d.ts +8 -1
- package/node_modules/@slack/logger/node_modules/@types/node/stream/web.d.ts +5 -2
- package/node_modules/@slack/logger/node_modules/@types/node/stream.d.ts +2 -2
- package/node_modules/@slack/logger/node_modules/@types/node/test.d.ts +36 -5
- package/node_modules/@slack/logger/node_modules/@types/node/timers/promises.d.ts +1 -1
- package/node_modules/@slack/logger/node_modules/@types/node/tls.d.ts +6 -0
- package/node_modules/@slack/logger/node_modules/@types/node/ts5.6/index.d.ts +8 -10
- package/node_modules/@slack/logger/node_modules/@types/node/url.d.ts +7 -4
- package/node_modules/@slack/logger/node_modules/@types/node/util.d.ts +80 -10
- package/node_modules/@slack/logger/node_modules/@types/node/vm.d.ts +81 -27
- package/node_modules/@slack/logger/node_modules/@types/node/worker_threads.d.ts +1 -1
- package/node_modules/@slack/web-api/dist/WebClient.d.ts +36 -4
- package/node_modules/@slack/web-api/dist/WebClient.d.ts.map +1 -1
- package/node_modules/@slack/web-api/dist/WebClient.js +23 -10
- package/node_modules/@slack/web-api/dist/WebClient.js.map +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/assert.d.ts +2 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/crypto.d.ts +10 -9
- package/node_modules/@slack/web-api/node_modules/@types/node/events.d.ts +2 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/fs/promises.d.ts +15 -4
- package/node_modules/@slack/web-api/node_modules/@types/node/fs.d.ts +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/globals.d.ts +17 -48
- package/node_modules/@slack/web-api/node_modules/@types/node/http.d.ts +37 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/index.d.ts +8 -10
- package/node_modules/@slack/web-api/node_modules/@types/node/module.d.ts +91 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/package.json +4 -3
- package/node_modules/@slack/web-api/node_modules/@types/node/perf_hooks.d.ts +24 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/readline/promises.d.ts +14 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/readline.d.ts +58 -9
- package/node_modules/@slack/web-api/node_modules/@types/node/stream/promises.d.ts +8 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/stream/web.d.ts +5 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/stream.d.ts +2 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/test.d.ts +36 -5
- package/node_modules/@slack/web-api/node_modules/@types/node/timers/promises.d.ts +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/tls.d.ts +6 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/ts5.6/index.d.ts +8 -10
- package/node_modules/@slack/web-api/node_modules/@types/node/url.d.ts +7 -4
- package/node_modules/@slack/web-api/node_modules/@types/node/util.d.ts +80 -10
- package/node_modules/@slack/web-api/node_modules/@types/node/vm.d.ts +81 -27
- package/node_modules/@slack/web-api/node_modules/@types/node/worker_threads.d.ts +1 -1
- package/node_modules/@slack/web-api/package.json +1 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/assert.d.ts +2 -2
- package/node_modules/@types/cacheable-request/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/crypto.d.ts +10 -9
- package/node_modules/@types/cacheable-request/node_modules/@types/node/events.d.ts +2 -2
- package/node_modules/@types/cacheable-request/node_modules/@types/node/fs/promises.d.ts +15 -4
- package/node_modules/@types/cacheable-request/node_modules/@types/node/fs.d.ts +1 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/globals.d.ts +17 -48
- package/node_modules/@types/cacheable-request/node_modules/@types/node/http.d.ts +37 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/index.d.ts +8 -10
- package/node_modules/@types/cacheable-request/node_modules/@types/node/module.d.ts +91 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/package.json +4 -3
- package/node_modules/@types/cacheable-request/node_modules/@types/node/perf_hooks.d.ts +24 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/readline/promises.d.ts +14 -2
- package/node_modules/@types/cacheable-request/node_modules/@types/node/readline.d.ts +58 -9
- package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/promises.d.ts +8 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/web.d.ts +5 -2
- package/node_modules/@types/cacheable-request/node_modules/@types/node/stream.d.ts +2 -2
- package/node_modules/@types/cacheable-request/node_modules/@types/node/test.d.ts +36 -5
- package/node_modules/@types/cacheable-request/node_modules/@types/node/timers/promises.d.ts +1 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/tls.d.ts +6 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/ts5.6/index.d.ts +8 -10
- package/node_modules/@types/cacheable-request/node_modules/@types/node/url.d.ts +7 -4
- package/node_modules/@types/cacheable-request/node_modules/@types/node/util.d.ts +80 -10
- package/node_modules/@types/cacheable-request/node_modules/@types/node/vm.d.ts +81 -27
- package/node_modules/@types/cacheable-request/node_modules/@types/node/worker_threads.d.ts +1 -1
- package/node_modules/@types/keyv/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/keyv/node_modules/@types/node/assert.d.ts +2 -2
- package/node_modules/@types/keyv/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/node_modules/@types/keyv/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@types/keyv/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
- package/node_modules/@types/keyv/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/node_modules/@types/keyv/node_modules/@types/node/crypto.d.ts +10 -9
- package/node_modules/@types/keyv/node_modules/@types/node/events.d.ts +2 -2
- package/node_modules/@types/keyv/node_modules/@types/node/fs/promises.d.ts +15 -4
- package/node_modules/@types/keyv/node_modules/@types/node/fs.d.ts +1 -1
- package/node_modules/@types/keyv/node_modules/@types/node/globals.d.ts +17 -48
- package/node_modules/@types/keyv/node_modules/@types/node/http.d.ts +37 -0
- package/node_modules/@types/keyv/node_modules/@types/node/index.d.ts +8 -10
- package/node_modules/@types/keyv/node_modules/@types/node/module.d.ts +91 -0
- package/node_modules/@types/keyv/node_modules/@types/node/package.json +4 -3
- package/node_modules/@types/keyv/node_modules/@types/node/perf_hooks.d.ts +24 -0
- package/node_modules/@types/keyv/node_modules/@types/node/readline/promises.d.ts +14 -2
- package/node_modules/@types/keyv/node_modules/@types/node/readline.d.ts +58 -9
- package/node_modules/@types/keyv/node_modules/@types/node/stream/promises.d.ts +8 -1
- package/node_modules/@types/keyv/node_modules/@types/node/stream/web.d.ts +5 -2
- package/node_modules/@types/keyv/node_modules/@types/node/stream.d.ts +2 -2
- package/node_modules/@types/keyv/node_modules/@types/node/test.d.ts +36 -5
- package/node_modules/@types/keyv/node_modules/@types/node/timers/promises.d.ts +1 -1
- package/node_modules/@types/keyv/node_modules/@types/node/tls.d.ts +6 -0
- package/node_modules/@types/keyv/node_modules/@types/node/ts5.6/index.d.ts +8 -10
- package/node_modules/@types/keyv/node_modules/@types/node/url.d.ts +7 -4
- package/node_modules/@types/keyv/node_modules/@types/node/util.d.ts +80 -10
- package/node_modules/@types/keyv/node_modules/@types/node/vm.d.ts +81 -27
- package/node_modules/@types/keyv/node_modules/@types/node/worker_threads.d.ts +1 -1
- package/node_modules/@types/responselike/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/responselike/node_modules/@types/node/assert.d.ts +2 -2
- package/node_modules/@types/responselike/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/node_modules/@types/responselike/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@types/responselike/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
- package/node_modules/@types/responselike/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/node_modules/@types/responselike/node_modules/@types/node/crypto.d.ts +10 -9
- package/node_modules/@types/responselike/node_modules/@types/node/events.d.ts +2 -2
- package/node_modules/@types/responselike/node_modules/@types/node/fs/promises.d.ts +15 -4
- package/node_modules/@types/responselike/node_modules/@types/node/fs.d.ts +1 -1
- package/node_modules/@types/responselike/node_modules/@types/node/globals.d.ts +17 -48
- package/node_modules/@types/responselike/node_modules/@types/node/http.d.ts +37 -0
- package/node_modules/@types/responselike/node_modules/@types/node/index.d.ts +8 -10
- package/node_modules/@types/responselike/node_modules/@types/node/module.d.ts +91 -0
- package/node_modules/@types/responselike/node_modules/@types/node/package.json +4 -3
- package/node_modules/@types/responselike/node_modules/@types/node/perf_hooks.d.ts +24 -0
- package/node_modules/@types/responselike/node_modules/@types/node/readline/promises.d.ts +14 -2
- package/node_modules/@types/responselike/node_modules/@types/node/readline.d.ts +58 -9
- package/node_modules/@types/responselike/node_modules/@types/node/stream/promises.d.ts +8 -1
- package/node_modules/@types/responselike/node_modules/@types/node/stream/web.d.ts +5 -2
- package/node_modules/@types/responselike/node_modules/@types/node/stream.d.ts +2 -2
- package/node_modules/@types/responselike/node_modules/@types/node/test.d.ts +36 -5
- package/node_modules/@types/responselike/node_modules/@types/node/timers/promises.d.ts +1 -1
- package/node_modules/@types/responselike/node_modules/@types/node/tls.d.ts +6 -0
- package/node_modules/@types/responselike/node_modules/@types/node/ts5.6/index.d.ts +8 -10
- package/node_modules/@types/responselike/node_modules/@types/node/url.d.ts +7 -4
- package/node_modules/@types/responselike/node_modules/@types/node/util.d.ts +80 -10
- package/node_modules/@types/responselike/node_modules/@types/node/vm.d.ts +81 -27
- package/node_modules/@types/responselike/node_modules/@types/node/worker_threads.d.ts +1 -1
- package/node_modules/cross-spawn/README.md +3 -10
- package/node_modules/cross-spawn/lib/enoent.js +1 -1
- package/node_modules/cross-spawn/lib/util/escape.js +4 -2
- package/node_modules/cross-spawn/package.json +1 -1
- package/node_modules/form-data/Readme.md +4 -4
- package/node_modules/form-data/lib/form_data.js +1 -1
- package/node_modules/form-data/package.json +9 -6
- package/node_modules/parse5/dist/cjs/common/doctype.d.ts +0 -1
- package/node_modules/parse5/dist/cjs/common/doctype.js +2 -4
- package/node_modules/parse5/dist/cjs/common/error-codes.d.ts +0 -1
- package/node_modules/parse5/dist/cjs/common/error-codes.js +1 -2
- package/node_modules/parse5/dist/cjs/common/foreign-content.d.ts +0 -1
- package/node_modules/parse5/dist/cjs/common/foreign-content.js +7 -9
- package/node_modules/parse5/dist/cjs/common/html.d.ts +32 -31
- package/node_modules/parse5/dist/cjs/common/html.js +41 -42
- package/node_modules/parse5/dist/cjs/common/token.d.ts +0 -1
- package/node_modules/parse5/dist/cjs/common/token.js +3 -4
- package/node_modules/parse5/dist/cjs/common/unicode.d.ts +1 -8
- package/node_modules/parse5/dist/cjs/common/unicode.js +7 -14
- package/node_modules/parse5/dist/cjs/index.d.ts +15 -4
- package/node_modules/parse5/dist/cjs/index.js +3 -6
- package/node_modules/parse5/dist/cjs/parser/formatting-element-list.d.ts +0 -1
- package/node_modules/parse5/dist/cjs/parser/formatting-element-list.js +1 -2
- package/node_modules/parse5/dist/cjs/parser/index.d.ts +72 -8
- package/node_modules/parse5/dist/cjs/parser/index.js +81 -9
- package/node_modules/parse5/dist/cjs/parser/open-element-stack.d.ts +2 -2
- package/node_modules/parse5/dist/cjs/parser/open-element-stack.js +95 -87
- package/node_modules/parse5/dist/cjs/serializer/index.d.ts +1 -2
- package/node_modules/parse5/dist/cjs/serializer/index.js +8 -9
- package/node_modules/parse5/dist/cjs/tokenizer/index.d.ts +130 -131
- package/node_modules/parse5/dist/cjs/tokenizer/index.js +87 -281
- package/node_modules/parse5/dist/cjs/tokenizer/preprocessor.d.ts +3 -4
- package/node_modules/parse5/dist/cjs/tokenizer/preprocessor.js +8 -7
- package/node_modules/parse5/dist/cjs/tree-adapters/default.d.ts +0 -1
- package/node_modules/parse5/dist/cjs/tree-adapters/default.js +9 -10
- package/node_modules/parse5/dist/cjs/tree-adapters/interface.d.ts +7 -2
- package/node_modules/parse5/dist/cjs/tree-adapters/interface.js +0 -1
- package/node_modules/parse5/dist/common/doctype.d.ts +0 -1
- package/node_modules/parse5/dist/common/doctype.js +0 -1
- package/node_modules/parse5/dist/common/error-codes.d.ts +0 -1
- package/node_modules/parse5/dist/common/error-codes.js +1 -2
- package/node_modules/parse5/dist/common/foreign-content.d.ts +0 -1
- package/node_modules/parse5/dist/common/foreign-content.js +0 -2
- package/node_modules/parse5/dist/common/html.d.ts +32 -31
- package/node_modules/parse5/dist/common/html.js +38 -38
- package/node_modules/parse5/dist/common/token.d.ts +0 -1
- package/node_modules/parse5/dist/common/token.js +1 -2
- package/node_modules/parse5/dist/common/unicode.d.ts +1 -8
- package/node_modules/parse5/dist/common/unicode.js +1 -8
- package/node_modules/parse5/dist/index.d.ts +15 -4
- package/node_modules/parse5/dist/index.js +0 -3
- package/node_modules/parse5/dist/parser/formatting-element-list.d.ts +0 -1
- package/node_modules/parse5/dist/parser/formatting-element-list.js +1 -2
- package/node_modules/parse5/dist/parser/index.d.ts +72 -8
- package/node_modules/parse5/dist/parser/index.js +82 -10
- package/node_modules/parse5/dist/parser/open-element-stack.d.ts +2 -2
- package/node_modules/parse5/dist/parser/open-element-stack.js +96 -88
- package/node_modules/parse5/dist/serializer/index.d.ts +1 -2
- package/node_modules/parse5/dist/serializer/index.js +6 -6
- package/node_modules/parse5/dist/tokenizer/index.d.ts +130 -131
- package/node_modules/parse5/dist/tokenizer/index.js +88 -282
- package/node_modules/parse5/dist/tokenizer/preprocessor.d.ts +3 -4
- package/node_modules/parse5/dist/tokenizer/preprocessor.js +8 -7
- package/node_modules/parse5/dist/tree-adapters/default.d.ts +0 -1
- package/node_modules/parse5/dist/tree-adapters/default.js +9 -10
- package/node_modules/parse5/dist/tree-adapters/interface.d.ts +7 -2
- package/node_modules/parse5/dist/tree-adapters/interface.js +0 -1
- package/node_modules/parse5/package.json +4 -4
- package/node_modules/parse5-htmlparser2-tree-adapter/dist/cjs/index.d.ts +1 -2
- package/node_modules/parse5-htmlparser2-tree-adapter/dist/cjs/index.js +11 -12
- package/node_modules/parse5-htmlparser2-tree-adapter/dist/index.d.ts +1 -2
- package/node_modules/parse5-htmlparser2-tree-adapter/dist/index.js +9 -10
- package/node_modules/parse5-htmlparser2-tree-adapter/package.json +7 -6
- package/package.json +21 -20
- package/node_modules/@slack/logger/node_modules/@types/node/globals.global.d.ts +0 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/globals.global.d.ts +0 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/globals.global.d.ts +0 -1
- package/node_modules/@types/keyv/node_modules/@types/node/globals.global.d.ts +0 -1
- package/node_modules/@types/responselike/node_modules/@types/node/globals.global.d.ts +0 -1
- package/node_modules/form-data/README.md.bak +0 -358
|
@@ -1,39 +1,9 @@
|
|
|
1
1
|
import { Preprocessor } from './preprocessor.js';
|
|
2
2
|
import { CODE_POINTS as $, SEQUENCES as $$, REPLACEMENT_CHARACTER, isSurrogate, isUndefinedCodePoint, isControlCodePoint, } from '../common/unicode.js';
|
|
3
3
|
import { TokenType, getTokenAttr, } from '../common/token.js';
|
|
4
|
-
import { htmlDecodeTree,
|
|
4
|
+
import { htmlDecodeTree, EntityDecoder, DecodingMode } from 'entities/lib/decode.js';
|
|
5
5
|
import { ERR } from '../common/error-codes.js';
|
|
6
6
|
import { TAG_ID, getTagID } from '../common/html.js';
|
|
7
|
-
//C1 Unicode control character reference replacements
|
|
8
|
-
const C1_CONTROLS_REFERENCE_REPLACEMENTS = new Map([
|
|
9
|
-
[0x80, 8364],
|
|
10
|
-
[0x82, 8218],
|
|
11
|
-
[0x83, 402],
|
|
12
|
-
[0x84, 8222],
|
|
13
|
-
[0x85, 8230],
|
|
14
|
-
[0x86, 8224],
|
|
15
|
-
[0x87, 8225],
|
|
16
|
-
[0x88, 710],
|
|
17
|
-
[0x89, 8240],
|
|
18
|
-
[0x8a, 352],
|
|
19
|
-
[0x8b, 8249],
|
|
20
|
-
[0x8c, 338],
|
|
21
|
-
[0x8e, 381],
|
|
22
|
-
[0x91, 8216],
|
|
23
|
-
[0x92, 8217],
|
|
24
|
-
[0x93, 8220],
|
|
25
|
-
[0x94, 8221],
|
|
26
|
-
[0x95, 8226],
|
|
27
|
-
[0x96, 8211],
|
|
28
|
-
[0x97, 8212],
|
|
29
|
-
[0x98, 732],
|
|
30
|
-
[0x99, 8482],
|
|
31
|
-
[0x9a, 353],
|
|
32
|
-
[0x9b, 8250],
|
|
33
|
-
[0x9c, 339],
|
|
34
|
-
[0x9e, 382],
|
|
35
|
-
[0x9f, 376],
|
|
36
|
-
]);
|
|
37
7
|
//States
|
|
38
8
|
var State;
|
|
39
9
|
(function (State) {
|
|
@@ -109,13 +79,7 @@ var State;
|
|
|
109
79
|
State[State["CDATA_SECTION_BRACKET"] = 69] = "CDATA_SECTION_BRACKET";
|
|
110
80
|
State[State["CDATA_SECTION_END"] = 70] = "CDATA_SECTION_END";
|
|
111
81
|
State[State["CHARACTER_REFERENCE"] = 71] = "CHARACTER_REFERENCE";
|
|
112
|
-
State[State["
|
|
113
|
-
State[State["AMBIGUOUS_AMPERSAND"] = 73] = "AMBIGUOUS_AMPERSAND";
|
|
114
|
-
State[State["NUMERIC_CHARACTER_REFERENCE"] = 74] = "NUMERIC_CHARACTER_REFERENCE";
|
|
115
|
-
State[State["HEXADEMICAL_CHARACTER_REFERENCE_START"] = 75] = "HEXADEMICAL_CHARACTER_REFERENCE_START";
|
|
116
|
-
State[State["HEXADEMICAL_CHARACTER_REFERENCE"] = 76] = "HEXADEMICAL_CHARACTER_REFERENCE";
|
|
117
|
-
State[State["DECIMAL_CHARACTER_REFERENCE"] = 77] = "DECIMAL_CHARACTER_REFERENCE";
|
|
118
|
-
State[State["NUMERIC_CHARACTER_REFERENCE_END"] = 78] = "NUMERIC_CHARACTER_REFERENCE_END";
|
|
82
|
+
State[State["AMBIGUOUS_AMPERSAND"] = 72] = "AMBIGUOUS_AMPERSAND";
|
|
119
83
|
})(State || (State = {}));
|
|
120
84
|
//Tokenizer initial states for different modes
|
|
121
85
|
export const TokenizerMode = {
|
|
@@ -145,27 +109,33 @@ function isAsciiLetter(cp) {
|
|
|
145
109
|
function isAsciiAlphaNumeric(cp) {
|
|
146
110
|
return isAsciiLetter(cp) || isAsciiDigit(cp);
|
|
147
111
|
}
|
|
148
|
-
function isAsciiUpperHexDigit(cp) {
|
|
149
|
-
return cp >= $.LATIN_CAPITAL_A && cp <= $.LATIN_CAPITAL_F;
|
|
150
|
-
}
|
|
151
|
-
function isAsciiLowerHexDigit(cp) {
|
|
152
|
-
return cp >= $.LATIN_SMALL_A && cp <= $.LATIN_SMALL_F;
|
|
153
|
-
}
|
|
154
|
-
function isAsciiHexDigit(cp) {
|
|
155
|
-
return isAsciiDigit(cp) || isAsciiUpperHexDigit(cp) || isAsciiLowerHexDigit(cp);
|
|
156
|
-
}
|
|
157
112
|
function toAsciiLower(cp) {
|
|
158
113
|
return cp + 32;
|
|
159
114
|
}
|
|
160
115
|
function isWhitespace(cp) {
|
|
161
116
|
return cp === $.SPACE || cp === $.LINE_FEED || cp === $.TABULATION || cp === $.FORM_FEED;
|
|
162
117
|
}
|
|
163
|
-
function isEntityInAttributeInvalidEnd(nextCp) {
|
|
164
|
-
return nextCp === $.EQUALS_SIGN || isAsciiAlphaNumeric(nextCp);
|
|
165
|
-
}
|
|
166
118
|
function isScriptDataDoubleEscapeSequenceEnd(cp) {
|
|
167
119
|
return isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN;
|
|
168
120
|
}
|
|
121
|
+
function getErrorForNumericCharacterReference(code) {
|
|
122
|
+
if (code === $.NULL) {
|
|
123
|
+
return ERR.nullCharacterReference;
|
|
124
|
+
}
|
|
125
|
+
else if (code > 1114111) {
|
|
126
|
+
return ERR.characterReferenceOutsideUnicodeRange;
|
|
127
|
+
}
|
|
128
|
+
else if (isSurrogate(code)) {
|
|
129
|
+
return ERR.surrogateCharacterReference;
|
|
130
|
+
}
|
|
131
|
+
else if (isUndefinedCodePoint(code)) {
|
|
132
|
+
return ERR.noncharacterCharacterReference;
|
|
133
|
+
}
|
|
134
|
+
else if (isControlCodePoint(code) || code === $.CARRIAGE_RETURN) {
|
|
135
|
+
return ERR.controlCharacterReference;
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
169
139
|
//Tokenizer
|
|
170
140
|
export class Tokenizer {
|
|
171
141
|
constructor(options, handler) {
|
|
@@ -185,18 +155,38 @@ export class Tokenizer {
|
|
|
185
155
|
this.active = false;
|
|
186
156
|
this.state = State.DATA;
|
|
187
157
|
this.returnState = State.DATA;
|
|
188
|
-
this.
|
|
158
|
+
this.entityStartPos = 0;
|
|
189
159
|
this.consumedAfterSnapshot = -1;
|
|
190
160
|
this.currentCharacterToken = null;
|
|
191
161
|
this.currentToken = null;
|
|
192
162
|
this.currentAttr = { name: '', value: '' };
|
|
193
163
|
this.preprocessor = new Preprocessor(handler);
|
|
194
164
|
this.currentLocation = this.getCurrentLocation(-1);
|
|
165
|
+
this.entityDecoder = new EntityDecoder(htmlDecodeTree, (cp, consumed) => {
|
|
166
|
+
// Note: Set `pos` _before_ flushing, as flushing might drop
|
|
167
|
+
// the current chunk and invalidate `entityStartPos`.
|
|
168
|
+
this.preprocessor.pos = this.entityStartPos + consumed - 1;
|
|
169
|
+
this._flushCodePointConsumedAsCharacterReference(cp);
|
|
170
|
+
}, handler.onParseError
|
|
171
|
+
? {
|
|
172
|
+
missingSemicolonAfterCharacterReference: () => {
|
|
173
|
+
this._err(ERR.missingSemicolonAfterCharacterReference, 1);
|
|
174
|
+
},
|
|
175
|
+
absenceOfDigitsInNumericCharacterReference: (consumed) => {
|
|
176
|
+
this._err(ERR.absenceOfDigitsInNumericCharacterReference, this.entityStartPos - this.preprocessor.pos + consumed);
|
|
177
|
+
},
|
|
178
|
+
validateNumericCharacterReference: (code) => {
|
|
179
|
+
const error = getErrorForNumericCharacterReference(code);
|
|
180
|
+
if (error)
|
|
181
|
+
this._err(error, 1);
|
|
182
|
+
},
|
|
183
|
+
}
|
|
184
|
+
: undefined);
|
|
195
185
|
}
|
|
196
186
|
//Errors
|
|
197
|
-
_err(code) {
|
|
187
|
+
_err(code, cpOffset = 0) {
|
|
198
188
|
var _a, _b;
|
|
199
|
-
(_b = (_a = this.handler).onParseError) === null || _b === void 0 ? void 0 : _b.call(_a, this.preprocessor.getError(code));
|
|
189
|
+
(_b = (_a = this.handler).onParseError) === null || _b === void 0 ? void 0 : _b.call(_a, this.preprocessor.getError(code, cpOffset));
|
|
200
190
|
}
|
|
201
191
|
// NOTE: `offset` may never run across line boundaries.
|
|
202
192
|
getCurrentLocation(offset) {
|
|
@@ -258,7 +248,8 @@ export class Tokenizer {
|
|
|
258
248
|
//Hibernation
|
|
259
249
|
_ensureHibernation() {
|
|
260
250
|
if (this.preprocessor.endOfChunkHit) {
|
|
261
|
-
this.
|
|
251
|
+
this.preprocessor.retreat(this.consumedAfterSnapshot);
|
|
252
|
+
this.consumedAfterSnapshot = 0;
|
|
262
253
|
this.active = false;
|
|
263
254
|
return true;
|
|
264
255
|
}
|
|
@@ -269,14 +260,6 @@ export class Tokenizer {
|
|
|
269
260
|
this.consumedAfterSnapshot++;
|
|
270
261
|
return this.preprocessor.advance();
|
|
271
262
|
}
|
|
272
|
-
_unconsume(count) {
|
|
273
|
-
this.consumedAfterSnapshot -= count;
|
|
274
|
-
this.preprocessor.retreat(count);
|
|
275
|
-
}
|
|
276
|
-
_reconsumeInState(state, cp) {
|
|
277
|
-
this.state = state;
|
|
278
|
-
this._callState(cp);
|
|
279
|
-
}
|
|
280
263
|
_advanceBy(count) {
|
|
281
264
|
this.consumedAfterSnapshot += count;
|
|
282
265
|
for (let i = 0; i < count; i++) {
|
|
@@ -448,7 +431,7 @@ export class Tokenizer {
|
|
|
448
431
|
this.active = false;
|
|
449
432
|
}
|
|
450
433
|
//Characters emission
|
|
451
|
-
//OPTIMIZATION: specification uses only one type of character
|
|
434
|
+
//OPTIMIZATION: The specification uses only one type of character token (one token per character).
|
|
452
435
|
//This causes a huge memory overhead and a lot of unnecessary parser loops. parse5 uses 3 groups of characters.
|
|
453
436
|
//If we have a sequence of characters that belong to the same group, the parser can process it
|
|
454
437
|
//as a single solid character token.
|
|
@@ -458,15 +441,15 @@ export class Tokenizer {
|
|
|
458
441
|
//3)TokenType.CHARACTER - any character sequence which don't belong to groups 1 and 2 (e.g. 'abcdef1234@@#$%^')
|
|
459
442
|
_appendCharToCurrentCharacterToken(type, ch) {
|
|
460
443
|
if (this.currentCharacterToken) {
|
|
461
|
-
if (this.currentCharacterToken.type
|
|
444
|
+
if (this.currentCharacterToken.type === type) {
|
|
445
|
+
this.currentCharacterToken.chars += ch;
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
462
449
|
this.currentLocation = this.getCurrentLocation(0);
|
|
463
450
|
this._emitCurrentCharacterToken(this.currentLocation);
|
|
464
451
|
this.preprocessor.dropParsedChunk();
|
|
465
452
|
}
|
|
466
|
-
else {
|
|
467
|
-
this.currentCharacterToken.chars += ch;
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
453
|
}
|
|
471
454
|
this._createCharacterToken(type, ch);
|
|
472
455
|
}
|
|
@@ -484,59 +467,11 @@ export class Tokenizer {
|
|
|
484
467
|
this._appendCharToCurrentCharacterToken(TokenType.CHARACTER, ch);
|
|
485
468
|
}
|
|
486
469
|
// Character reference helpers
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
i = determineBranch(htmlDecodeTree, current, i + 1, cp);
|
|
493
|
-
if (i < 0)
|
|
494
|
-
break;
|
|
495
|
-
excess += 1;
|
|
496
|
-
current = htmlDecodeTree[i];
|
|
497
|
-
const masked = current & BinTrieFlags.VALUE_LENGTH;
|
|
498
|
-
// If the branch is a value, store it and continue
|
|
499
|
-
if (masked) {
|
|
500
|
-
// The mask is the number of bytes of the value, including the current byte.
|
|
501
|
-
const valueLength = (masked >> 14) - 1;
|
|
502
|
-
// Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
|
|
503
|
-
// See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
|
|
504
|
-
if (cp !== $.SEMICOLON &&
|
|
505
|
-
this._isCharacterReferenceInAttribute() &&
|
|
506
|
-
isEntityInAttributeInvalidEnd(this.preprocessor.peek(1))) {
|
|
507
|
-
//NOTE: we don't flush all consumed code points here, and instead switch back to the original state after
|
|
508
|
-
//emitting an ampersand. This is fine, as alphanumeric characters won't be parsed differently in attributes.
|
|
509
|
-
result = [$.AMPERSAND];
|
|
510
|
-
// Skip over the value.
|
|
511
|
-
i += valueLength;
|
|
512
|
-
}
|
|
513
|
-
else {
|
|
514
|
-
// If this is a surrogate pair, consume the next two bytes.
|
|
515
|
-
result =
|
|
516
|
-
valueLength === 0
|
|
517
|
-
? [htmlDecodeTree[i] & ~BinTrieFlags.VALUE_LENGTH]
|
|
518
|
-
: valueLength === 1
|
|
519
|
-
? [htmlDecodeTree[++i]]
|
|
520
|
-
: [htmlDecodeTree[++i], htmlDecodeTree[++i]];
|
|
521
|
-
excess = 0;
|
|
522
|
-
withoutSemicolon = cp !== $.SEMICOLON;
|
|
523
|
-
}
|
|
524
|
-
if (valueLength === 0) {
|
|
525
|
-
// If the value is zero-length, we're done.
|
|
526
|
-
this._consume();
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
this._unconsume(excess);
|
|
532
|
-
if (withoutSemicolon && !this.preprocessor.endOfChunkHit) {
|
|
533
|
-
this._err(ERR.missingSemicolonAfterCharacterReference);
|
|
534
|
-
}
|
|
535
|
-
// We want to emit the error above on the code point after the entity.
|
|
536
|
-
// We always consume one code point too many in the loop, and we wait to
|
|
537
|
-
// unconsume it until after the error is emitted.
|
|
538
|
-
this._unconsume(1);
|
|
539
|
-
return result;
|
|
470
|
+
_startCharacterReference() {
|
|
471
|
+
this.returnState = this.state;
|
|
472
|
+
this.state = State.CHARACTER_REFERENCE;
|
|
473
|
+
this.entityStartPos = this.preprocessor.pos;
|
|
474
|
+
this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute() ? DecodingMode.Attribute : DecodingMode.Legacy);
|
|
540
475
|
}
|
|
541
476
|
_isCharacterReferenceInAttribute() {
|
|
542
477
|
return (this.returnState === State.ATTRIBUTE_VALUE_DOUBLE_QUOTED ||
|
|
@@ -839,37 +774,13 @@ export class Tokenizer {
|
|
|
839
774
|
break;
|
|
840
775
|
}
|
|
841
776
|
case State.CHARACTER_REFERENCE: {
|
|
842
|
-
this._stateCharacterReference(
|
|
843
|
-
break;
|
|
844
|
-
}
|
|
845
|
-
case State.NAMED_CHARACTER_REFERENCE: {
|
|
846
|
-
this._stateNamedCharacterReference(cp);
|
|
777
|
+
this._stateCharacterReference();
|
|
847
778
|
break;
|
|
848
779
|
}
|
|
849
780
|
case State.AMBIGUOUS_AMPERSAND: {
|
|
850
781
|
this._stateAmbiguousAmpersand(cp);
|
|
851
782
|
break;
|
|
852
783
|
}
|
|
853
|
-
case State.NUMERIC_CHARACTER_REFERENCE: {
|
|
854
|
-
this._stateNumericCharacterReference(cp);
|
|
855
|
-
break;
|
|
856
|
-
}
|
|
857
|
-
case State.HEXADEMICAL_CHARACTER_REFERENCE_START: {
|
|
858
|
-
this._stateHexademicalCharacterReferenceStart(cp);
|
|
859
|
-
break;
|
|
860
|
-
}
|
|
861
|
-
case State.HEXADEMICAL_CHARACTER_REFERENCE: {
|
|
862
|
-
this._stateHexademicalCharacterReference(cp);
|
|
863
|
-
break;
|
|
864
|
-
}
|
|
865
|
-
case State.DECIMAL_CHARACTER_REFERENCE: {
|
|
866
|
-
this._stateDecimalCharacterReference(cp);
|
|
867
|
-
break;
|
|
868
|
-
}
|
|
869
|
-
case State.NUMERIC_CHARACTER_REFERENCE_END: {
|
|
870
|
-
this._stateNumericCharacterReferenceEnd(cp);
|
|
871
|
-
break;
|
|
872
|
-
}
|
|
873
784
|
default: {
|
|
874
785
|
throw new Error('Unknown state');
|
|
875
786
|
}
|
|
@@ -885,8 +796,7 @@ export class Tokenizer {
|
|
|
885
796
|
break;
|
|
886
797
|
}
|
|
887
798
|
case $.AMPERSAND: {
|
|
888
|
-
this.
|
|
889
|
-
this.state = State.CHARACTER_REFERENCE;
|
|
799
|
+
this._startCharacterReference();
|
|
890
800
|
break;
|
|
891
801
|
}
|
|
892
802
|
case $.NULL: {
|
|
@@ -908,8 +818,7 @@ export class Tokenizer {
|
|
|
908
818
|
_stateRcdata(cp) {
|
|
909
819
|
switch (cp) {
|
|
910
820
|
case $.AMPERSAND: {
|
|
911
|
-
this.
|
|
912
|
-
this.state = State.CHARACTER_REFERENCE;
|
|
821
|
+
this._startCharacterReference();
|
|
913
822
|
break;
|
|
914
823
|
}
|
|
915
824
|
case $.LESS_THAN_SIGN: {
|
|
@@ -1678,8 +1587,7 @@ export class Tokenizer {
|
|
|
1678
1587
|
break;
|
|
1679
1588
|
}
|
|
1680
1589
|
case $.AMPERSAND: {
|
|
1681
|
-
this.
|
|
1682
|
-
this.state = State.CHARACTER_REFERENCE;
|
|
1590
|
+
this._startCharacterReference();
|
|
1683
1591
|
break;
|
|
1684
1592
|
}
|
|
1685
1593
|
case $.NULL: {
|
|
@@ -1706,8 +1614,7 @@ export class Tokenizer {
|
|
|
1706
1614
|
break;
|
|
1707
1615
|
}
|
|
1708
1616
|
case $.AMPERSAND: {
|
|
1709
|
-
this.
|
|
1710
|
-
this.state = State.CHARACTER_REFERENCE;
|
|
1617
|
+
this._startCharacterReference();
|
|
1711
1618
|
break;
|
|
1712
1619
|
}
|
|
1713
1620
|
case $.NULL: {
|
|
@@ -1738,8 +1645,7 @@ export class Tokenizer {
|
|
|
1738
1645
|
break;
|
|
1739
1646
|
}
|
|
1740
1647
|
case $.AMPERSAND: {
|
|
1741
|
-
this.
|
|
1742
|
-
this.state = State.CHARACTER_REFERENCE;
|
|
1648
|
+
this._startCharacterReference();
|
|
1743
1649
|
break;
|
|
1744
1650
|
}
|
|
1745
1651
|
case $.GREATER_THAN_SIGN: {
|
|
@@ -2756,37 +2662,35 @@ export class Tokenizer {
|
|
|
2756
2662
|
}
|
|
2757
2663
|
// Character reference state
|
|
2758
2664
|
//------------------------------------------------------------------
|
|
2759
|
-
_stateCharacterReference(
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2665
|
+
_stateCharacterReference() {
|
|
2666
|
+
let length = this.entityDecoder.write(this.preprocessor.html, this.preprocessor.pos);
|
|
2667
|
+
if (length < 0) {
|
|
2668
|
+
if (this.preprocessor.lastChunkWritten) {
|
|
2669
|
+
length = this.entityDecoder.end();
|
|
2670
|
+
}
|
|
2671
|
+
else {
|
|
2672
|
+
// Wait for the rest of the entity.
|
|
2673
|
+
this.active = false;
|
|
2674
|
+
// Mark the entire buffer as read.
|
|
2675
|
+
this.preprocessor.pos = this.preprocessor.html.length - 1;
|
|
2676
|
+
this.consumedAfterSnapshot = 0;
|
|
2677
|
+
this.preprocessor.endOfChunkHit = true;
|
|
2678
|
+
return;
|
|
2679
|
+
}
|
|
2766
2680
|
}
|
|
2767
|
-
|
|
2681
|
+
if (length === 0) {
|
|
2682
|
+
// This was not a valid entity. Go back to the beginning, and
|
|
2683
|
+
// figure out what to do.
|
|
2684
|
+
this.preprocessor.pos = this.entityStartPos;
|
|
2768
2685
|
this._flushCodePointConsumedAsCharacterReference($.AMPERSAND);
|
|
2769
|
-
this.
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
//------------------------------------------------------------------
|
|
2774
|
-
_stateNamedCharacterReference(cp) {
|
|
2775
|
-
const matchResult = this._matchNamedCharacterReference(cp);
|
|
2776
|
-
//NOTE: Matching can be abrupted by hibernation. In that case, match
|
|
2777
|
-
//results are no longer valid and we will need to start over.
|
|
2778
|
-
if (this._ensureHibernation()) {
|
|
2779
|
-
// Stay in the state, try again.
|
|
2780
|
-
}
|
|
2781
|
-
else if (matchResult) {
|
|
2782
|
-
for (let i = 0; i < matchResult.length; i++) {
|
|
2783
|
-
this._flushCodePointConsumedAsCharacterReference(matchResult[i]);
|
|
2784
|
-
}
|
|
2785
|
-
this.state = this.returnState;
|
|
2686
|
+
this.state =
|
|
2687
|
+
!this._isCharacterReferenceInAttribute() && isAsciiAlphaNumeric(this.preprocessor.peek(1))
|
|
2688
|
+
? State.AMBIGUOUS_AMPERSAND
|
|
2689
|
+
: this.returnState;
|
|
2786
2690
|
}
|
|
2787
2691
|
else {
|
|
2788
|
-
|
|
2789
|
-
this.state =
|
|
2692
|
+
// We successfully parsed an entity. Switch to the return state.
|
|
2693
|
+
this.state = this.returnState;
|
|
2790
2694
|
}
|
|
2791
2695
|
}
|
|
2792
2696
|
// Ambiguos ampersand state
|
|
@@ -2799,106 +2703,8 @@ export class Tokenizer {
|
|
|
2799
2703
|
if (cp === $.SEMICOLON) {
|
|
2800
2704
|
this._err(ERR.unknownNamedCharacterReference);
|
|
2801
2705
|
}
|
|
2802
|
-
this._reconsumeInState(this.returnState, cp);
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2805
|
-
// Numeric character reference state
|
|
2806
|
-
//------------------------------------------------------------------
|
|
2807
|
-
_stateNumericCharacterReference(cp) {
|
|
2808
|
-
this.charRefCode = 0;
|
|
2809
|
-
if (cp === $.LATIN_SMALL_X || cp === $.LATIN_CAPITAL_X) {
|
|
2810
|
-
this.state = State.HEXADEMICAL_CHARACTER_REFERENCE_START;
|
|
2811
|
-
}
|
|
2812
|
-
// Inlined decimal character reference start state
|
|
2813
|
-
else if (isAsciiDigit(cp)) {
|
|
2814
|
-
this.state = State.DECIMAL_CHARACTER_REFERENCE;
|
|
2815
|
-
this._stateDecimalCharacterReference(cp);
|
|
2816
|
-
}
|
|
2817
|
-
else {
|
|
2818
|
-
this._err(ERR.absenceOfDigitsInNumericCharacterReference);
|
|
2819
|
-
this._flushCodePointConsumedAsCharacterReference($.AMPERSAND);
|
|
2820
|
-
this._flushCodePointConsumedAsCharacterReference($.NUMBER_SIGN);
|
|
2821
|
-
this._reconsumeInState(this.returnState, cp);
|
|
2822
|
-
}
|
|
2823
|
-
}
|
|
2824
|
-
// Hexademical character reference start state
|
|
2825
|
-
//------------------------------------------------------------------
|
|
2826
|
-
_stateHexademicalCharacterReferenceStart(cp) {
|
|
2827
|
-
if (isAsciiHexDigit(cp)) {
|
|
2828
|
-
this.state = State.HEXADEMICAL_CHARACTER_REFERENCE;
|
|
2829
|
-
this._stateHexademicalCharacterReference(cp);
|
|
2830
|
-
}
|
|
2831
|
-
else {
|
|
2832
|
-
this._err(ERR.absenceOfDigitsInNumericCharacterReference);
|
|
2833
|
-
this._flushCodePointConsumedAsCharacterReference($.AMPERSAND);
|
|
2834
|
-
this._flushCodePointConsumedAsCharacterReference($.NUMBER_SIGN);
|
|
2835
|
-
this._unconsume(2);
|
|
2836
2706
|
this.state = this.returnState;
|
|
2707
|
+
this._callState(cp);
|
|
2837
2708
|
}
|
|
2838
2709
|
}
|
|
2839
|
-
// Hexademical character reference state
|
|
2840
|
-
//------------------------------------------------------------------
|
|
2841
|
-
_stateHexademicalCharacterReference(cp) {
|
|
2842
|
-
if (isAsciiUpperHexDigit(cp)) {
|
|
2843
|
-
this.charRefCode = this.charRefCode * 16 + cp - 0x37;
|
|
2844
|
-
}
|
|
2845
|
-
else if (isAsciiLowerHexDigit(cp)) {
|
|
2846
|
-
this.charRefCode = this.charRefCode * 16 + cp - 0x57;
|
|
2847
|
-
}
|
|
2848
|
-
else if (isAsciiDigit(cp)) {
|
|
2849
|
-
this.charRefCode = this.charRefCode * 16 + cp - 0x30;
|
|
2850
|
-
}
|
|
2851
|
-
else if (cp === $.SEMICOLON) {
|
|
2852
|
-
this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
|
|
2853
|
-
}
|
|
2854
|
-
else {
|
|
2855
|
-
this._err(ERR.missingSemicolonAfterCharacterReference);
|
|
2856
|
-
this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
|
|
2857
|
-
this._stateNumericCharacterReferenceEnd(cp);
|
|
2858
|
-
}
|
|
2859
|
-
}
|
|
2860
|
-
// Decimal character reference state
|
|
2861
|
-
//------------------------------------------------------------------
|
|
2862
|
-
_stateDecimalCharacterReference(cp) {
|
|
2863
|
-
if (isAsciiDigit(cp)) {
|
|
2864
|
-
this.charRefCode = this.charRefCode * 10 + cp - 0x30;
|
|
2865
|
-
}
|
|
2866
|
-
else if (cp === $.SEMICOLON) {
|
|
2867
|
-
this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
|
|
2868
|
-
}
|
|
2869
|
-
else {
|
|
2870
|
-
this._err(ERR.missingSemicolonAfterCharacterReference);
|
|
2871
|
-
this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
|
|
2872
|
-
this._stateNumericCharacterReferenceEnd(cp);
|
|
2873
|
-
}
|
|
2874
|
-
}
|
|
2875
|
-
// Numeric character reference end state
|
|
2876
|
-
//------------------------------------------------------------------
|
|
2877
|
-
_stateNumericCharacterReferenceEnd(cp) {
|
|
2878
|
-
if (this.charRefCode === $.NULL) {
|
|
2879
|
-
this._err(ERR.nullCharacterReference);
|
|
2880
|
-
this.charRefCode = $.REPLACEMENT_CHARACTER;
|
|
2881
|
-
}
|
|
2882
|
-
else if (this.charRefCode > 1114111) {
|
|
2883
|
-
this._err(ERR.characterReferenceOutsideUnicodeRange);
|
|
2884
|
-
this.charRefCode = $.REPLACEMENT_CHARACTER;
|
|
2885
|
-
}
|
|
2886
|
-
else if (isSurrogate(this.charRefCode)) {
|
|
2887
|
-
this._err(ERR.surrogateCharacterReference);
|
|
2888
|
-
this.charRefCode = $.REPLACEMENT_CHARACTER;
|
|
2889
|
-
}
|
|
2890
|
-
else if (isUndefinedCodePoint(this.charRefCode)) {
|
|
2891
|
-
this._err(ERR.noncharacterCharacterReference);
|
|
2892
|
-
}
|
|
2893
|
-
else if (isControlCodePoint(this.charRefCode) || this.charRefCode === $.CARRIAGE_RETURN) {
|
|
2894
|
-
this._err(ERR.controlCharacterReference);
|
|
2895
|
-
const replacement = C1_CONTROLS_REFERENCE_REPLACEMENTS.get(this.charRefCode);
|
|
2896
|
-
if (replacement !== undefined) {
|
|
2897
|
-
this.charRefCode = replacement;
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2900
|
-
this._flushCodePointConsumedAsCharacterReference(this.charRefCode);
|
|
2901
|
-
this._reconsumeInState(this.returnState, cp);
|
|
2902
|
-
}
|
|
2903
2710
|
}
|
|
2904
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -2,11 +2,11 @@ import { ERR, type ParserError, type ParserErrorHandler } from '../common/error-
|
|
|
2
2
|
export declare class Preprocessor {
|
|
3
3
|
private handler;
|
|
4
4
|
html: string;
|
|
5
|
-
|
|
5
|
+
pos: number;
|
|
6
6
|
private lastGapPos;
|
|
7
7
|
private gapStack;
|
|
8
8
|
private skipNextNewLine;
|
|
9
|
-
|
|
9
|
+
lastChunkWritten: boolean;
|
|
10
10
|
endOfChunkHit: boolean;
|
|
11
11
|
bufferWaterline: number;
|
|
12
12
|
private isEol;
|
|
@@ -19,7 +19,7 @@ export declare class Preprocessor {
|
|
|
19
19
|
/** The column on the current line. If we just saw a gap (eg. a surrogate pair), return the index before. */
|
|
20
20
|
get col(): number;
|
|
21
21
|
get offset(): number;
|
|
22
|
-
getError(code: ERR): ParserError;
|
|
22
|
+
getError(code: ERR, cpOffset: number): ParserError;
|
|
23
23
|
private lastErrOffset;
|
|
24
24
|
private _err;
|
|
25
25
|
private _addGap;
|
|
@@ -34,4 +34,3 @@ export declare class Preprocessor {
|
|
|
34
34
|
private _checkForProblematicCharacters;
|
|
35
35
|
retreat(count: number): void;
|
|
36
36
|
}
|
|
37
|
-
//# sourceMappingURL=preprocessor.d.ts.map
|
|
@@ -31,22 +31,24 @@ export class Preprocessor {
|
|
|
31
31
|
get offset() {
|
|
32
32
|
return this.droppedBufferSize + this.pos;
|
|
33
33
|
}
|
|
34
|
-
getError(code) {
|
|
34
|
+
getError(code, cpOffset) {
|
|
35
35
|
const { line, col, offset } = this;
|
|
36
|
+
const startCol = col + cpOffset;
|
|
37
|
+
const startOffset = offset + cpOffset;
|
|
36
38
|
return {
|
|
37
39
|
code,
|
|
38
40
|
startLine: line,
|
|
39
41
|
endLine: line,
|
|
40
|
-
startCol
|
|
41
|
-
endCol:
|
|
42
|
-
startOffset
|
|
43
|
-
endOffset:
|
|
42
|
+
startCol,
|
|
43
|
+
endCol: startCol,
|
|
44
|
+
startOffset,
|
|
45
|
+
endOffset: startOffset,
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
_err(code) {
|
|
47
49
|
if (this.handler.onParseError && this.lastErrOffset !== this.offset) {
|
|
48
50
|
this.lastErrOffset = this.offset;
|
|
49
|
-
this.handler.onParseError(this.getError(code));
|
|
51
|
+
this.handler.onParseError(this.getError(code, 0));
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
_addGap() {
|
|
@@ -192,4 +194,3 @@ export class Preprocessor {
|
|
|
192
194
|
this.isEol = false;
|
|
193
195
|
}
|
|
194
196
|
}
|
|
195
|
-
//# sourceMappingURL=preprocessor.js.map
|
|
@@ -82,4 +82,3 @@ export type ChildNode = Element | Template | CommentNode | TextNode | DocumentTy
|
|
|
82
82
|
export type Node = ParentNode | ChildNode;
|
|
83
83
|
export type DefaultTreeAdapterMap = TreeAdapterTypeMap<Node, ParentNode, ChildNode, Document, DocumentFragment, Element, CommentNode, TextNode, Template, DocumentType>;
|
|
84
84
|
export declare const defaultTreeAdapter: TreeAdapter<DefaultTreeAdapterMap>;
|
|
85
|
-
//# sourceMappingURL=default.d.ts.map
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { DOCUMENT_MODE } from '../common/html.js';
|
|
2
|
-
function createTextNode(value) {
|
|
3
|
-
return {
|
|
4
|
-
nodeName: '#text',
|
|
5
|
-
value,
|
|
6
|
-
parentNode: null,
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
2
|
export const defaultTreeAdapter = {
|
|
10
3
|
//Node construction
|
|
11
4
|
createDocument() {
|
|
@@ -38,6 +31,13 @@ export const defaultTreeAdapter = {
|
|
|
38
31
|
parentNode: null,
|
|
39
32
|
};
|
|
40
33
|
},
|
|
34
|
+
createTextNode(value) {
|
|
35
|
+
return {
|
|
36
|
+
nodeName: '#text',
|
|
37
|
+
value,
|
|
38
|
+
parentNode: null,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
41
|
//Tree mutation
|
|
42
42
|
appendChild(parentNode, newNode) {
|
|
43
43
|
parentNode.childNodes.push(newNode);
|
|
@@ -93,7 +93,7 @@ export const defaultTreeAdapter = {
|
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
defaultTreeAdapter.appendChild(parentNode, createTextNode(text));
|
|
96
|
+
defaultTreeAdapter.appendChild(parentNode, defaultTreeAdapter.createTextNode(text));
|
|
97
97
|
},
|
|
98
98
|
insertTextBefore(parentNode, text, referenceNode) {
|
|
99
99
|
const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
|
|
@@ -101,7 +101,7 @@ export const defaultTreeAdapter = {
|
|
|
101
101
|
prevNode.value += text;
|
|
102
102
|
}
|
|
103
103
|
else {
|
|
104
|
-
defaultTreeAdapter.insertBefore(parentNode, createTextNode(text), referenceNode);
|
|
104
|
+
defaultTreeAdapter.insertBefore(parentNode, defaultTreeAdapter.createTextNode(text), referenceNode);
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
adoptAttributes(recipient, attrs) {
|
|
@@ -171,4 +171,3 @@ export const defaultTreeAdapter = {
|
|
|
171
171
|
node.sourceCodeLocation = { ...node.sourceCodeLocation, ...endLocation };
|
|
172
172
|
},
|
|
173
173
|
};
|
|
174
|
-
//# sourceMappingURL=default.js.map
|
|
@@ -17,7 +17,7 @@ export interface TreeAdapterTypeMap<Node = unknown, ParentNode = unknown, ChildN
|
|
|
17
17
|
* Note that `TreeAdapter` is not designed to be a general purpose AST manipulation library. You can build such library
|
|
18
18
|
* on top of existing `TreeAdapter` or use one of the existing libraries from npm.
|
|
19
19
|
*
|
|
20
|
-
* @see
|
|
20
|
+
* @see Have a look at the default tree adapter for reference.
|
|
21
21
|
*/
|
|
22
22
|
export interface TreeAdapter<T extends TreeAdapterTypeMap = TreeAdapterTypeMap> {
|
|
23
23
|
/**
|
|
@@ -40,6 +40,12 @@ export interface TreeAdapter<T extends TreeAdapterTypeMap = TreeAdapterTypeMap>
|
|
|
40
40
|
* @param data - Comment text.
|
|
41
41
|
*/
|
|
42
42
|
createCommentNode(data: string): T['commentNode'];
|
|
43
|
+
/**
|
|
44
|
+
* Creates a text node.
|
|
45
|
+
*
|
|
46
|
+
* @param value - Text.
|
|
47
|
+
*/
|
|
48
|
+
createTextNode(value: string): T['textNode'];
|
|
43
49
|
/**
|
|
44
50
|
* Creates a document node.
|
|
45
51
|
*/
|
|
@@ -247,4 +253,3 @@ export interface TreeAdapter<T extends TreeAdapterTypeMap = TreeAdapterTypeMap>
|
|
|
247
253
|
*/
|
|
248
254
|
onItemPop?: (item: T['element'], newTop: T['parentNode']) => void;
|
|
249
255
|
}
|
|
250
|
-
//# sourceMappingURL=interface.d.ts.map
|