aizryu.js 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/replit/__replit_disk_meta.json +1 -0
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/replit/nix/env.json +1 -0
- package/.cache/typescript/5.0/node_modules/.package-lock.json +156 -0
- package/.cache/typescript/5.0/node_modules/@types/body-parser/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/body-parser/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/body-parser/index.d.ts +95 -0
- package/.cache/typescript/5.0/node_modules/@types/body-parser/package.json +58 -0
- package/.cache/typescript/5.0/node_modules/@types/connect/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/connect/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/connect/index.d.ts +91 -0
- package/.cache/typescript/5.0/node_modules/@types/connect/package.json +32 -0
- package/.cache/typescript/5.0/node_modules/@types/express/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/express/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/express/index.d.ts +128 -0
- package/.cache/typescript/5.0/node_modules/@types/express/package.json +45 -0
- package/.cache/typescript/5.0/node_modules/@types/express-serve-static-core/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/express-serve-static-core/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/express-serve-static-core/index.d.ts +1261 -0
- package/.cache/typescript/5.0/node_modules/@types/express-serve-static-core/package.json +55 -0
- package/.cache/typescript/5.0/node_modules/@types/http-errors/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/http-errors/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/http-errors/index.d.ts +77 -0
- package/.cache/typescript/5.0/node_modules/@types/http-errors/package.json +30 -0
- package/.cache/typescript/5.0/node_modules/@types/jsdom/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/jsdom/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/jsdom/base.d.ts +456 -0
- package/.cache/typescript/5.0/node_modules/@types/jsdom/index.d.ts +18 -0
- package/.cache/typescript/5.0/node_modules/@types/jsdom/package.json +45 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/Mime.d.ts +10 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/index.d.ts +31 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/lite.d.ts +7 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/package.json +30 -0
- package/.cache/typescript/5.0/node_modules/@types/node/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/node/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.0/node_modules/@types/node/assert.d.ts +996 -0
- package/.cache/typescript/5.0/node_modules/@types/node/async_hooks.d.ts +539 -0
- package/.cache/typescript/5.0/node_modules/@types/node/buffer.d.ts +2362 -0
- package/.cache/typescript/5.0/node_modules/@types/node/child_process.d.ts +1540 -0
- package/.cache/typescript/5.0/node_modules/@types/node/cluster.d.ts +432 -0
- package/.cache/typescript/5.0/node_modules/@types/node/console.d.ts +415 -0
- package/.cache/typescript/5.0/node_modules/@types/node/constants.d.ts +19 -0
- package/.cache/typescript/5.0/node_modules/@types/node/crypto.d.ts +4456 -0
- package/.cache/typescript/5.0/node_modules/@types/node/dgram.d.ts +586 -0
- package/.cache/typescript/5.0/node_modules/@types/node/diagnostics_channel.d.ts +191 -0
- package/.cache/typescript/5.0/node_modules/@types/node/dns/promises.d.ts +425 -0
- package/.cache/typescript/5.0/node_modules/@types/node/dns.d.ts +809 -0
- package/.cache/typescript/5.0/node_modules/@types/node/dom-events.d.ts +122 -0
- package/.cache/typescript/5.0/node_modules/@types/node/domain.d.ts +170 -0
- package/.cache/typescript/5.0/node_modules/@types/node/events.d.ts +879 -0
- package/.cache/typescript/5.0/node_modules/@types/node/fs/promises.d.ts +1239 -0
- package/.cache/typescript/5.0/node_modules/@types/node/fs.d.ts +4291 -0
- package/.cache/typescript/5.0/node_modules/@types/node/globals.d.ts +381 -0
- package/.cache/typescript/5.0/node_modules/@types/node/globals.global.d.ts +1 -0
- package/.cache/typescript/5.0/node_modules/@types/node/http.d.ts +1888 -0
- package/.cache/typescript/5.0/node_modules/@types/node/http2.d.ts +2382 -0
- package/.cache/typescript/5.0/node_modules/@types/node/https.d.ts +550 -0
- package/.cache/typescript/5.0/node_modules/@types/node/index.d.ts +88 -0
- package/.cache/typescript/5.0/node_modules/@types/node/inspector.d.ts +2747 -0
- package/.cache/typescript/5.0/node_modules/@types/node/module.d.ts +301 -0
- package/.cache/typescript/5.0/node_modules/@types/node/net.d.ts +949 -0
- package/.cache/typescript/5.0/node_modules/@types/node/os.d.ts +478 -0
- package/.cache/typescript/5.0/node_modules/@types/node/package.json +230 -0
- package/.cache/typescript/5.0/node_modules/@types/node/path.d.ts +191 -0
- package/.cache/typescript/5.0/node_modules/@types/node/perf_hooks.d.ts +639 -0
- package/.cache/typescript/5.0/node_modules/@types/node/process.d.ts +1532 -0
- package/.cache/typescript/5.0/node_modules/@types/node/punycode.d.ts +117 -0
- package/.cache/typescript/5.0/node_modules/@types/node/querystring.d.ts +141 -0
- package/.cache/typescript/5.0/node_modules/@types/node/readline/promises.d.ts +150 -0
- package/.cache/typescript/5.0/node_modules/@types/node/readline.d.ts +539 -0
- package/.cache/typescript/5.0/node_modules/@types/node/repl.d.ts +430 -0
- package/.cache/typescript/5.0/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.0/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/.cache/typescript/5.0/node_modules/@types/node/stream/web.d.ts +350 -0
- package/.cache/typescript/5.0/node_modules/@types/node/stream.d.ts +1701 -0
- package/.cache/typescript/5.0/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.0/node_modules/@types/node/test.d.ts +1382 -0
- package/.cache/typescript/5.0/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/.cache/typescript/5.0/node_modules/@types/node/timers.d.ts +240 -0
- package/.cache/typescript/5.0/node_modules/@types/node/tls.d.ts +1210 -0
- package/.cache/typescript/5.0/node_modules/@types/node/trace_events.d.ts +182 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/assert.d.ts +996 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/async_hooks.d.ts +539 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/buffer.d.ts +2362 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/child_process.d.ts +1540 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/cluster.d.ts +432 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/console.d.ts +415 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/constants.d.ts +19 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/crypto.d.ts +4455 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/dgram.d.ts +586 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +191 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/dns/promises.d.ts +425 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/dns.d.ts +809 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/dom-events.d.ts +122 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/events.d.ts +879 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/fs/promises.d.ts +1239 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/fs.d.ts +4291 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/globals.d.ts +381 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/http.d.ts +1888 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/http2.d.ts +2382 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/https.d.ts +550 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/index.d.ts +88 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/inspector.d.ts +2747 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/module.d.ts +301 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/net.d.ts +949 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/os.d.ts +478 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/path.d.ts +191 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/perf_hooks.d.ts +639 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/process.d.ts +1532 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/querystring.d.ts +141 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/readline/promises.d.ts +150 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/readline.d.ts +539 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/repl.d.ts +430 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/stream/promises.d.ts +83 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/stream/web.d.ts +350 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/stream.d.ts +1701 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/test.d.ts +1382 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/timers.d.ts +240 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/tls.d.ts +1210 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/trace_events.d.ts +182 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/tty.d.ts +208 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/url.d.ts +927 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/util.d.ts +2186 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/v8.d.ts +635 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/vm.d.ts +903 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/worker_threads.d.ts +691 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
- package/.cache/typescript/5.0/node_modules/@types/node/tty.d.ts +208 -0
- package/.cache/typescript/5.0/node_modules/@types/node/url.d.ts +927 -0
- package/.cache/typescript/5.0/node_modules/@types/node/util.d.ts +2186 -0
- package/.cache/typescript/5.0/node_modules/@types/node/v8.d.ts +635 -0
- package/.cache/typescript/5.0/node_modules/@types/node/vm.d.ts +903 -0
- package/.cache/typescript/5.0/node_modules/@types/node/wasi.d.ts +158 -0
- package/.cache/typescript/5.0/node_modules/@types/node/worker_threads.d.ts +691 -0
- package/.cache/typescript/5.0/node_modules/@types/node/zlib.d.ts +517 -0
- package/.cache/typescript/5.0/node_modules/@types/qs/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/qs/README.md +75 -0
- package/.cache/typescript/5.0/node_modules/@types/qs/index.d.ts +56 -0
- package/.cache/typescript/5.0/node_modules/@types/qs/package.json +65 -0
- package/.cache/typescript/5.0/node_modules/@types/range-parser/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/range-parser/README.md +53 -0
- package/.cache/typescript/5.0/node_modules/@types/range-parser/index.d.ts +34 -0
- package/.cache/typescript/5.0/node_modules/@types/range-parser/package.json +25 -0
- package/.cache/typescript/5.0/node_modules/@types/send/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/send/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/send/index.d.ts +225 -0
- package/.cache/typescript/5.0/node_modules/@types/send/package.json +33 -0
- package/.cache/typescript/5.0/node_modules/@types/serve-static/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/serve-static/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/serve-static/index.d.ts +107 -0
- package/.cache/typescript/5.0/node_modules/@types/serve-static/package.json +39 -0
- package/.cache/typescript/5.0/node_modules/@types/tough-cookie/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/tough-cookie/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/tough-cookie/index.d.ts +321 -0
- package/.cache/typescript/5.0/node_modules/@types/tough-cookie/package.json +35 -0
- package/.cache/typescript/5.0/node_modules/entities/LICENSE +11 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode.d.ts +211 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode.js +536 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode_codepoint.d.ts +19 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode_codepoint.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode_codepoint.js +76 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode_codepoint.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/encode.d.ts +22 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/encode.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/encode.js +77 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/encode.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/escape.d.ts +43 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/escape.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/escape.js +122 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/escape.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode.d.ts +211 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode.js +496 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode_codepoint.d.ts +19 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode_codepoint.js +71 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode_codepoint.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/encode.d.ts +22 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/encode.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/encode.js +69 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/encode.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/escape.d.ts +43 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/escape.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/escape.js +116 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/escape.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +3 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-html.js +7 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-html.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +3 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-xml.js +7 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/encode-html.d.ts +8 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/encode-html.js +10 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/encode-html.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/index.d.ts +96 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/index.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/index.js +99 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/index.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/package.json +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-html.d.ts +3 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-html.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-html.js +9 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-html.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-xml.d.ts +3 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-xml.js +9 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-xml.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/encode-html.d.ts +8 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/encode-html.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/encode-html.js +12 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/encode-html.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/index.d.ts +96 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/index.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/index.js +126 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/index.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/package.json +90 -0
- package/.cache/typescript/5.0/node_modules/entities/readme.md +122 -0
- package/.cache/typescript/5.0/node_modules/parse5/LICENSE +19 -0
- package/.cache/typescript/5.0/node_modules/parse5/README.md +38 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/doctype.d.ts +5 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/doctype.js +120 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/error-codes.d.ts +68 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/error-codes.js +67 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/foreign-content.d.ts +10 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/foreign-content.js +239 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/html.d.ts +288 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/html.js +529 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/token.d.ts +85 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/token.js +25 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/unicode.d.ts +49 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/unicode.js +77 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/index.d.ts +60 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/index.js +57 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/package.json +1 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/formatting-element-list.d.ts +37 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/formatting-element-list.js +115 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/index.d.ts +157 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/index.js +3163 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/open-element-stack.d.ts +53 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/open-element-stack.js +316 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/serializer/index.d.ts +61 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/serializer/index.js +173 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tokenizer/index.d.ts +248 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tokenizer/index.js +2908 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tokenizer/preprocessor.d.ts +37 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tokenizer/preprocessor.js +199 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tree-adapters/default.d.ts +85 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tree-adapters/default.js +177 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tree-adapters/interface.d.ts +250 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tree-adapters/interface.js +3 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/doctype.d.ts +5 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/doctype.js +115 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/error-codes.d.ts +68 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/error-codes.js +64 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/foreign-content.d.ts +10 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/foreign-content.js +230 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/html.d.ts +288 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/html.js +523 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/token.d.ts +85 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/token.js +21 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/unicode.d.ts +49 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/unicode.js +69 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/index.d.ts +60 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/index.js +45 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/formatting-element-list.d.ts +37 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/formatting-element-list.js +111 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/index.d.ts +157 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/index.js +3168 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/open-element-stack.d.ts +53 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/open-element-stack.js +312 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/serializer/index.d.ts +61 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/serializer/index.js +168 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tokenizer/index.d.ts +248 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tokenizer/index.js +2904 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tokenizer/preprocessor.d.ts +37 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tokenizer/preprocessor.js +195 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tree-adapters/default.d.ts +85 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tree-adapters/default.js +174 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tree-adapters/interface.d.ts +250 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tree-adapters/interface.js +2 -0
- package/.cache/typescript/5.0/node_modules/parse5/package.json +50 -0
- package/.cache/typescript/5.0/node_modules/types-registry/README.md +2 -0
- package/.cache/typescript/5.0/node_modules/types-registry/index.json +1 -0
- package/.cache/typescript/5.0/node_modules/types-registry/package.json +20 -0
- package/.cache/typescript/5.0/node_modules/undici-types/README.md +6 -0
- package/.cache/typescript/5.0/node_modules/undici-types/agent.d.ts +31 -0
- package/.cache/typescript/5.0/node_modules/undici-types/api.d.ts +43 -0
- package/.cache/typescript/5.0/node_modules/undici-types/balanced-pool.d.ts +18 -0
- package/.cache/typescript/5.0/node_modules/undici-types/cache.d.ts +36 -0
- package/.cache/typescript/5.0/node_modules/undici-types/client.d.ts +97 -0
- package/.cache/typescript/5.0/node_modules/undici-types/connector.d.ts +34 -0
- package/.cache/typescript/5.0/node_modules/undici-types/content-type.d.ts +21 -0
- package/.cache/typescript/5.0/node_modules/undici-types/cookies.d.ts +28 -0
- package/.cache/typescript/5.0/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
- package/.cache/typescript/5.0/node_modules/undici-types/dispatcher.d.ts +241 -0
- package/.cache/typescript/5.0/node_modules/undici-types/errors.d.ts +128 -0
- package/.cache/typescript/5.0/node_modules/undici-types/fetch.d.ts +209 -0
- package/.cache/typescript/5.0/node_modules/undici-types/file.d.ts +39 -0
- package/.cache/typescript/5.0/node_modules/undici-types/filereader.d.ts +54 -0
- package/.cache/typescript/5.0/node_modules/undici-types/formdata.d.ts +108 -0
- package/.cache/typescript/5.0/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/.cache/typescript/5.0/node_modules/undici-types/global-origin.d.ts +7 -0
- package/.cache/typescript/5.0/node_modules/undici-types/handlers.d.ts +9 -0
- package/.cache/typescript/5.0/node_modules/undici-types/header.d.ts +4 -0
- package/.cache/typescript/5.0/node_modules/undici-types/index.d.ts +63 -0
- package/.cache/typescript/5.0/node_modules/undici-types/interceptors.d.ts +5 -0
- package/.cache/typescript/5.0/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/.cache/typescript/5.0/node_modules/undici-types/mock-client.d.ts +25 -0
- package/.cache/typescript/5.0/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/.cache/typescript/5.0/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/.cache/typescript/5.0/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/.cache/typescript/5.0/node_modules/undici-types/package.json +55 -0
- package/.cache/typescript/5.0/node_modules/undici-types/patch.d.ts +71 -0
- package/.cache/typescript/5.0/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/.cache/typescript/5.0/node_modules/undici-types/pool.d.ts +28 -0
- package/.cache/typescript/5.0/node_modules/undici-types/proxy-agent.d.ts +30 -0
- package/.cache/typescript/5.0/node_modules/undici-types/readable.d.ts +61 -0
- package/.cache/typescript/5.0/node_modules/undici-types/webidl.d.ts +220 -0
- package/.cache/typescript/5.0/node_modules/undici-types/websocket.d.ts +131 -0
- package/.cache/typescript/5.0/package-lock.json +166 -0
- package/.cache/typescript/5.0/package.json +1 -0
- package/.replit +14 -0
- package/.upm/store.json +1 -0
- package/README.md +24 -0
- package/index.js +1 -0
- package/package.json +21 -0
@@ -0,0 +1,2904 @@
|
|
1
|
+
import { Preprocessor } from './preprocessor.js';
|
2
|
+
import { CODE_POINTS as $, SEQUENCES as $$, REPLACEMENT_CHARACTER, isSurrogate, isUndefinedCodePoint, isControlCodePoint, } from '../common/unicode.js';
|
3
|
+
import { TokenType, getTokenAttr, } from '../common/token.js';
|
4
|
+
import { htmlDecodeTree, BinTrieFlags, determineBranch } from 'entities/lib/decode.js';
|
5
|
+
import { ERR } from '../common/error-codes.js';
|
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
|
+
//States
|
38
|
+
var State;
|
39
|
+
(function (State) {
|
40
|
+
State[State["DATA"] = 0] = "DATA";
|
41
|
+
State[State["RCDATA"] = 1] = "RCDATA";
|
42
|
+
State[State["RAWTEXT"] = 2] = "RAWTEXT";
|
43
|
+
State[State["SCRIPT_DATA"] = 3] = "SCRIPT_DATA";
|
44
|
+
State[State["PLAINTEXT"] = 4] = "PLAINTEXT";
|
45
|
+
State[State["TAG_OPEN"] = 5] = "TAG_OPEN";
|
46
|
+
State[State["END_TAG_OPEN"] = 6] = "END_TAG_OPEN";
|
47
|
+
State[State["TAG_NAME"] = 7] = "TAG_NAME";
|
48
|
+
State[State["RCDATA_LESS_THAN_SIGN"] = 8] = "RCDATA_LESS_THAN_SIGN";
|
49
|
+
State[State["RCDATA_END_TAG_OPEN"] = 9] = "RCDATA_END_TAG_OPEN";
|
50
|
+
State[State["RCDATA_END_TAG_NAME"] = 10] = "RCDATA_END_TAG_NAME";
|
51
|
+
State[State["RAWTEXT_LESS_THAN_SIGN"] = 11] = "RAWTEXT_LESS_THAN_SIGN";
|
52
|
+
State[State["RAWTEXT_END_TAG_OPEN"] = 12] = "RAWTEXT_END_TAG_OPEN";
|
53
|
+
State[State["RAWTEXT_END_TAG_NAME"] = 13] = "RAWTEXT_END_TAG_NAME";
|
54
|
+
State[State["SCRIPT_DATA_LESS_THAN_SIGN"] = 14] = "SCRIPT_DATA_LESS_THAN_SIGN";
|
55
|
+
State[State["SCRIPT_DATA_END_TAG_OPEN"] = 15] = "SCRIPT_DATA_END_TAG_OPEN";
|
56
|
+
State[State["SCRIPT_DATA_END_TAG_NAME"] = 16] = "SCRIPT_DATA_END_TAG_NAME";
|
57
|
+
State[State["SCRIPT_DATA_ESCAPE_START"] = 17] = "SCRIPT_DATA_ESCAPE_START";
|
58
|
+
State[State["SCRIPT_DATA_ESCAPE_START_DASH"] = 18] = "SCRIPT_DATA_ESCAPE_START_DASH";
|
59
|
+
State[State["SCRIPT_DATA_ESCAPED"] = 19] = "SCRIPT_DATA_ESCAPED";
|
60
|
+
State[State["SCRIPT_DATA_ESCAPED_DASH"] = 20] = "SCRIPT_DATA_ESCAPED_DASH";
|
61
|
+
State[State["SCRIPT_DATA_ESCAPED_DASH_DASH"] = 21] = "SCRIPT_DATA_ESCAPED_DASH_DASH";
|
62
|
+
State[State["SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN"] = 22] = "SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN";
|
63
|
+
State[State["SCRIPT_DATA_ESCAPED_END_TAG_OPEN"] = 23] = "SCRIPT_DATA_ESCAPED_END_TAG_OPEN";
|
64
|
+
State[State["SCRIPT_DATA_ESCAPED_END_TAG_NAME"] = 24] = "SCRIPT_DATA_ESCAPED_END_TAG_NAME";
|
65
|
+
State[State["SCRIPT_DATA_DOUBLE_ESCAPE_START"] = 25] = "SCRIPT_DATA_DOUBLE_ESCAPE_START";
|
66
|
+
State[State["SCRIPT_DATA_DOUBLE_ESCAPED"] = 26] = "SCRIPT_DATA_DOUBLE_ESCAPED";
|
67
|
+
State[State["SCRIPT_DATA_DOUBLE_ESCAPED_DASH"] = 27] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH";
|
68
|
+
State[State["SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH"] = 28] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH";
|
69
|
+
State[State["SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN"] = 29] = "SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN";
|
70
|
+
State[State["SCRIPT_DATA_DOUBLE_ESCAPE_END"] = 30] = "SCRIPT_DATA_DOUBLE_ESCAPE_END";
|
71
|
+
State[State["BEFORE_ATTRIBUTE_NAME"] = 31] = "BEFORE_ATTRIBUTE_NAME";
|
72
|
+
State[State["ATTRIBUTE_NAME"] = 32] = "ATTRIBUTE_NAME";
|
73
|
+
State[State["AFTER_ATTRIBUTE_NAME"] = 33] = "AFTER_ATTRIBUTE_NAME";
|
74
|
+
State[State["BEFORE_ATTRIBUTE_VALUE"] = 34] = "BEFORE_ATTRIBUTE_VALUE";
|
75
|
+
State[State["ATTRIBUTE_VALUE_DOUBLE_QUOTED"] = 35] = "ATTRIBUTE_VALUE_DOUBLE_QUOTED";
|
76
|
+
State[State["ATTRIBUTE_VALUE_SINGLE_QUOTED"] = 36] = "ATTRIBUTE_VALUE_SINGLE_QUOTED";
|
77
|
+
State[State["ATTRIBUTE_VALUE_UNQUOTED"] = 37] = "ATTRIBUTE_VALUE_UNQUOTED";
|
78
|
+
State[State["AFTER_ATTRIBUTE_VALUE_QUOTED"] = 38] = "AFTER_ATTRIBUTE_VALUE_QUOTED";
|
79
|
+
State[State["SELF_CLOSING_START_TAG"] = 39] = "SELF_CLOSING_START_TAG";
|
80
|
+
State[State["BOGUS_COMMENT"] = 40] = "BOGUS_COMMENT";
|
81
|
+
State[State["MARKUP_DECLARATION_OPEN"] = 41] = "MARKUP_DECLARATION_OPEN";
|
82
|
+
State[State["COMMENT_START"] = 42] = "COMMENT_START";
|
83
|
+
State[State["COMMENT_START_DASH"] = 43] = "COMMENT_START_DASH";
|
84
|
+
State[State["COMMENT"] = 44] = "COMMENT";
|
85
|
+
State[State["COMMENT_LESS_THAN_SIGN"] = 45] = "COMMENT_LESS_THAN_SIGN";
|
86
|
+
State[State["COMMENT_LESS_THAN_SIGN_BANG"] = 46] = "COMMENT_LESS_THAN_SIGN_BANG";
|
87
|
+
State[State["COMMENT_LESS_THAN_SIGN_BANG_DASH"] = 47] = "COMMENT_LESS_THAN_SIGN_BANG_DASH";
|
88
|
+
State[State["COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH"] = 48] = "COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH";
|
89
|
+
State[State["COMMENT_END_DASH"] = 49] = "COMMENT_END_DASH";
|
90
|
+
State[State["COMMENT_END"] = 50] = "COMMENT_END";
|
91
|
+
State[State["COMMENT_END_BANG"] = 51] = "COMMENT_END_BANG";
|
92
|
+
State[State["DOCTYPE"] = 52] = "DOCTYPE";
|
93
|
+
State[State["BEFORE_DOCTYPE_NAME"] = 53] = "BEFORE_DOCTYPE_NAME";
|
94
|
+
State[State["DOCTYPE_NAME"] = 54] = "DOCTYPE_NAME";
|
95
|
+
State[State["AFTER_DOCTYPE_NAME"] = 55] = "AFTER_DOCTYPE_NAME";
|
96
|
+
State[State["AFTER_DOCTYPE_PUBLIC_KEYWORD"] = 56] = "AFTER_DOCTYPE_PUBLIC_KEYWORD";
|
97
|
+
State[State["BEFORE_DOCTYPE_PUBLIC_IDENTIFIER"] = 57] = "BEFORE_DOCTYPE_PUBLIC_IDENTIFIER";
|
98
|
+
State[State["DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED"] = 58] = "DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED";
|
99
|
+
State[State["DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED"] = 59] = "DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED";
|
100
|
+
State[State["AFTER_DOCTYPE_PUBLIC_IDENTIFIER"] = 60] = "AFTER_DOCTYPE_PUBLIC_IDENTIFIER";
|
101
|
+
State[State["BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS"] = 61] = "BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS";
|
102
|
+
State[State["AFTER_DOCTYPE_SYSTEM_KEYWORD"] = 62] = "AFTER_DOCTYPE_SYSTEM_KEYWORD";
|
103
|
+
State[State["BEFORE_DOCTYPE_SYSTEM_IDENTIFIER"] = 63] = "BEFORE_DOCTYPE_SYSTEM_IDENTIFIER";
|
104
|
+
State[State["DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED"] = 64] = "DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED";
|
105
|
+
State[State["DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED"] = 65] = "DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED";
|
106
|
+
State[State["AFTER_DOCTYPE_SYSTEM_IDENTIFIER"] = 66] = "AFTER_DOCTYPE_SYSTEM_IDENTIFIER";
|
107
|
+
State[State["BOGUS_DOCTYPE"] = 67] = "BOGUS_DOCTYPE";
|
108
|
+
State[State["CDATA_SECTION"] = 68] = "CDATA_SECTION";
|
109
|
+
State[State["CDATA_SECTION_BRACKET"] = 69] = "CDATA_SECTION_BRACKET";
|
110
|
+
State[State["CDATA_SECTION_END"] = 70] = "CDATA_SECTION_END";
|
111
|
+
State[State["CHARACTER_REFERENCE"] = 71] = "CHARACTER_REFERENCE";
|
112
|
+
State[State["NAMED_CHARACTER_REFERENCE"] = 72] = "NAMED_CHARACTER_REFERENCE";
|
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";
|
119
|
+
})(State || (State = {}));
|
120
|
+
//Tokenizer initial states for different modes
|
121
|
+
export const TokenizerMode = {
|
122
|
+
DATA: State.DATA,
|
123
|
+
RCDATA: State.RCDATA,
|
124
|
+
RAWTEXT: State.RAWTEXT,
|
125
|
+
SCRIPT_DATA: State.SCRIPT_DATA,
|
126
|
+
PLAINTEXT: State.PLAINTEXT,
|
127
|
+
CDATA_SECTION: State.CDATA_SECTION,
|
128
|
+
};
|
129
|
+
//Utils
|
130
|
+
//OPTIMIZATION: these utility functions should not be moved out of this module. V8 Crankshaft will not inline
|
131
|
+
//this functions if they will be situated in another module due to context switch.
|
132
|
+
//Always perform inlining check before modifying this functions ('node --trace-inlining').
|
133
|
+
function isAsciiDigit(cp) {
|
134
|
+
return cp >= $.DIGIT_0 && cp <= $.DIGIT_9;
|
135
|
+
}
|
136
|
+
function isAsciiUpper(cp) {
|
137
|
+
return cp >= $.LATIN_CAPITAL_A && cp <= $.LATIN_CAPITAL_Z;
|
138
|
+
}
|
139
|
+
function isAsciiLower(cp) {
|
140
|
+
return cp >= $.LATIN_SMALL_A && cp <= $.LATIN_SMALL_Z;
|
141
|
+
}
|
142
|
+
function isAsciiLetter(cp) {
|
143
|
+
return isAsciiLower(cp) || isAsciiUpper(cp);
|
144
|
+
}
|
145
|
+
function isAsciiAlphaNumeric(cp) {
|
146
|
+
return isAsciiLetter(cp) || isAsciiDigit(cp);
|
147
|
+
}
|
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
|
+
function toAsciiLower(cp) {
|
158
|
+
return cp + 32;
|
159
|
+
}
|
160
|
+
function isWhitespace(cp) {
|
161
|
+
return cp === $.SPACE || cp === $.LINE_FEED || cp === $.TABULATION || cp === $.FORM_FEED;
|
162
|
+
}
|
163
|
+
function isEntityInAttributeInvalidEnd(nextCp) {
|
164
|
+
return nextCp === $.EQUALS_SIGN || isAsciiAlphaNumeric(nextCp);
|
165
|
+
}
|
166
|
+
function isScriptDataDoubleEscapeSequenceEnd(cp) {
|
167
|
+
return isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN;
|
168
|
+
}
|
169
|
+
//Tokenizer
|
170
|
+
export class Tokenizer {
|
171
|
+
constructor(options, handler) {
|
172
|
+
this.options = options;
|
173
|
+
this.handler = handler;
|
174
|
+
this.paused = false;
|
175
|
+
/** Ensures that the parsing loop isn't run multiple times at once. */
|
176
|
+
this.inLoop = false;
|
177
|
+
/**
|
178
|
+
* Indicates that the current adjusted node exists, is not an element in the HTML namespace,
|
179
|
+
* and that it is not an integration point for either MathML or HTML.
|
180
|
+
*
|
181
|
+
* @see {@link https://html.spec.whatwg.org/multipage/parsing.html#tree-construction}
|
182
|
+
*/
|
183
|
+
this.inForeignNode = false;
|
184
|
+
this.lastStartTagName = '';
|
185
|
+
this.active = false;
|
186
|
+
this.state = State.DATA;
|
187
|
+
this.returnState = State.DATA;
|
188
|
+
this.charRefCode = -1;
|
189
|
+
this.consumedAfterSnapshot = -1;
|
190
|
+
this.currentCharacterToken = null;
|
191
|
+
this.currentToken = null;
|
192
|
+
this.currentAttr = { name: '', value: '' };
|
193
|
+
this.preprocessor = new Preprocessor(handler);
|
194
|
+
this.currentLocation = this.getCurrentLocation(-1);
|
195
|
+
}
|
196
|
+
//Errors
|
197
|
+
_err(code) {
|
198
|
+
var _a, _b;
|
199
|
+
(_b = (_a = this.handler).onParseError) === null || _b === void 0 ? void 0 : _b.call(_a, this.preprocessor.getError(code));
|
200
|
+
}
|
201
|
+
// NOTE: `offset` may never run across line boundaries.
|
202
|
+
getCurrentLocation(offset) {
|
203
|
+
if (!this.options.sourceCodeLocationInfo) {
|
204
|
+
return null;
|
205
|
+
}
|
206
|
+
return {
|
207
|
+
startLine: this.preprocessor.line,
|
208
|
+
startCol: this.preprocessor.col - offset,
|
209
|
+
startOffset: this.preprocessor.offset - offset,
|
210
|
+
endLine: -1,
|
211
|
+
endCol: -1,
|
212
|
+
endOffset: -1,
|
213
|
+
};
|
214
|
+
}
|
215
|
+
_runParsingLoop() {
|
216
|
+
if (this.inLoop)
|
217
|
+
return;
|
218
|
+
this.inLoop = true;
|
219
|
+
while (this.active && !this.paused) {
|
220
|
+
this.consumedAfterSnapshot = 0;
|
221
|
+
const cp = this._consume();
|
222
|
+
if (!this._ensureHibernation()) {
|
223
|
+
this._callState(cp);
|
224
|
+
}
|
225
|
+
}
|
226
|
+
this.inLoop = false;
|
227
|
+
}
|
228
|
+
//API
|
229
|
+
pause() {
|
230
|
+
this.paused = true;
|
231
|
+
}
|
232
|
+
resume(writeCallback) {
|
233
|
+
if (!this.paused) {
|
234
|
+
throw new Error('Parser was already resumed');
|
235
|
+
}
|
236
|
+
this.paused = false;
|
237
|
+
// Necessary for synchronous resume.
|
238
|
+
if (this.inLoop)
|
239
|
+
return;
|
240
|
+
this._runParsingLoop();
|
241
|
+
if (!this.paused) {
|
242
|
+
writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();
|
243
|
+
}
|
244
|
+
}
|
245
|
+
write(chunk, isLastChunk, writeCallback) {
|
246
|
+
this.active = true;
|
247
|
+
this.preprocessor.write(chunk, isLastChunk);
|
248
|
+
this._runParsingLoop();
|
249
|
+
if (!this.paused) {
|
250
|
+
writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();
|
251
|
+
}
|
252
|
+
}
|
253
|
+
insertHtmlAtCurrentPos(chunk) {
|
254
|
+
this.active = true;
|
255
|
+
this.preprocessor.insertHtmlAtCurrentPos(chunk);
|
256
|
+
this._runParsingLoop();
|
257
|
+
}
|
258
|
+
//Hibernation
|
259
|
+
_ensureHibernation() {
|
260
|
+
if (this.preprocessor.endOfChunkHit) {
|
261
|
+
this._unconsume(this.consumedAfterSnapshot);
|
262
|
+
this.active = false;
|
263
|
+
return true;
|
264
|
+
}
|
265
|
+
return false;
|
266
|
+
}
|
267
|
+
//Consumption
|
268
|
+
_consume() {
|
269
|
+
this.consumedAfterSnapshot++;
|
270
|
+
return this.preprocessor.advance();
|
271
|
+
}
|
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
|
+
_advanceBy(count) {
|
281
|
+
this.consumedAfterSnapshot += count;
|
282
|
+
for (let i = 0; i < count; i++) {
|
283
|
+
this.preprocessor.advance();
|
284
|
+
}
|
285
|
+
}
|
286
|
+
_consumeSequenceIfMatch(pattern, caseSensitive) {
|
287
|
+
if (this.preprocessor.startsWith(pattern, caseSensitive)) {
|
288
|
+
// We will already have consumed one character before calling this method.
|
289
|
+
this._advanceBy(pattern.length - 1);
|
290
|
+
return true;
|
291
|
+
}
|
292
|
+
return false;
|
293
|
+
}
|
294
|
+
//Token creation
|
295
|
+
_createStartTagToken() {
|
296
|
+
this.currentToken = {
|
297
|
+
type: TokenType.START_TAG,
|
298
|
+
tagName: '',
|
299
|
+
tagID: TAG_ID.UNKNOWN,
|
300
|
+
selfClosing: false,
|
301
|
+
ackSelfClosing: false,
|
302
|
+
attrs: [],
|
303
|
+
location: this.getCurrentLocation(1),
|
304
|
+
};
|
305
|
+
}
|
306
|
+
_createEndTagToken() {
|
307
|
+
this.currentToken = {
|
308
|
+
type: TokenType.END_TAG,
|
309
|
+
tagName: '',
|
310
|
+
tagID: TAG_ID.UNKNOWN,
|
311
|
+
selfClosing: false,
|
312
|
+
ackSelfClosing: false,
|
313
|
+
attrs: [],
|
314
|
+
location: this.getCurrentLocation(2),
|
315
|
+
};
|
316
|
+
}
|
317
|
+
_createCommentToken(offset) {
|
318
|
+
this.currentToken = {
|
319
|
+
type: TokenType.COMMENT,
|
320
|
+
data: '',
|
321
|
+
location: this.getCurrentLocation(offset),
|
322
|
+
};
|
323
|
+
}
|
324
|
+
_createDoctypeToken(initialName) {
|
325
|
+
this.currentToken = {
|
326
|
+
type: TokenType.DOCTYPE,
|
327
|
+
name: initialName,
|
328
|
+
forceQuirks: false,
|
329
|
+
publicId: null,
|
330
|
+
systemId: null,
|
331
|
+
location: this.currentLocation,
|
332
|
+
};
|
333
|
+
}
|
334
|
+
_createCharacterToken(type, chars) {
|
335
|
+
this.currentCharacterToken = {
|
336
|
+
type,
|
337
|
+
chars,
|
338
|
+
location: this.currentLocation,
|
339
|
+
};
|
340
|
+
}
|
341
|
+
//Tag attributes
|
342
|
+
_createAttr(attrNameFirstCh) {
|
343
|
+
this.currentAttr = {
|
344
|
+
name: attrNameFirstCh,
|
345
|
+
value: '',
|
346
|
+
};
|
347
|
+
this.currentLocation = this.getCurrentLocation(0);
|
348
|
+
}
|
349
|
+
_leaveAttrName() {
|
350
|
+
var _a;
|
351
|
+
var _b;
|
352
|
+
const token = this.currentToken;
|
353
|
+
if (getTokenAttr(token, this.currentAttr.name) === null) {
|
354
|
+
token.attrs.push(this.currentAttr);
|
355
|
+
if (token.location && this.currentLocation) {
|
356
|
+
const attrLocations = ((_a = (_b = token.location).attrs) !== null && _a !== void 0 ? _a : (_b.attrs = Object.create(null)));
|
357
|
+
attrLocations[this.currentAttr.name] = this.currentLocation;
|
358
|
+
// Set end location
|
359
|
+
this._leaveAttrValue();
|
360
|
+
}
|
361
|
+
}
|
362
|
+
else {
|
363
|
+
this._err(ERR.duplicateAttribute);
|
364
|
+
}
|
365
|
+
}
|
366
|
+
_leaveAttrValue() {
|
367
|
+
if (this.currentLocation) {
|
368
|
+
this.currentLocation.endLine = this.preprocessor.line;
|
369
|
+
this.currentLocation.endCol = this.preprocessor.col;
|
370
|
+
this.currentLocation.endOffset = this.preprocessor.offset;
|
371
|
+
}
|
372
|
+
}
|
373
|
+
//Token emission
|
374
|
+
prepareToken(ct) {
|
375
|
+
this._emitCurrentCharacterToken(ct.location);
|
376
|
+
this.currentToken = null;
|
377
|
+
if (ct.location) {
|
378
|
+
ct.location.endLine = this.preprocessor.line;
|
379
|
+
ct.location.endCol = this.preprocessor.col + 1;
|
380
|
+
ct.location.endOffset = this.preprocessor.offset + 1;
|
381
|
+
}
|
382
|
+
this.currentLocation = this.getCurrentLocation(-1);
|
383
|
+
}
|
384
|
+
emitCurrentTagToken() {
|
385
|
+
const ct = this.currentToken;
|
386
|
+
this.prepareToken(ct);
|
387
|
+
ct.tagID = getTagID(ct.tagName);
|
388
|
+
if (ct.type === TokenType.START_TAG) {
|
389
|
+
this.lastStartTagName = ct.tagName;
|
390
|
+
this.handler.onStartTag(ct);
|
391
|
+
}
|
392
|
+
else {
|
393
|
+
if (ct.attrs.length > 0) {
|
394
|
+
this._err(ERR.endTagWithAttributes);
|
395
|
+
}
|
396
|
+
if (ct.selfClosing) {
|
397
|
+
this._err(ERR.endTagWithTrailingSolidus);
|
398
|
+
}
|
399
|
+
this.handler.onEndTag(ct);
|
400
|
+
}
|
401
|
+
this.preprocessor.dropParsedChunk();
|
402
|
+
}
|
403
|
+
emitCurrentComment(ct) {
|
404
|
+
this.prepareToken(ct);
|
405
|
+
this.handler.onComment(ct);
|
406
|
+
this.preprocessor.dropParsedChunk();
|
407
|
+
}
|
408
|
+
emitCurrentDoctype(ct) {
|
409
|
+
this.prepareToken(ct);
|
410
|
+
this.handler.onDoctype(ct);
|
411
|
+
this.preprocessor.dropParsedChunk();
|
412
|
+
}
|
413
|
+
_emitCurrentCharacterToken(nextLocation) {
|
414
|
+
if (this.currentCharacterToken) {
|
415
|
+
//NOTE: if we have a pending character token, make it's end location equal to the
|
416
|
+
//current token's start location.
|
417
|
+
if (nextLocation && this.currentCharacterToken.location) {
|
418
|
+
this.currentCharacterToken.location.endLine = nextLocation.startLine;
|
419
|
+
this.currentCharacterToken.location.endCol = nextLocation.startCol;
|
420
|
+
this.currentCharacterToken.location.endOffset = nextLocation.startOffset;
|
421
|
+
}
|
422
|
+
switch (this.currentCharacterToken.type) {
|
423
|
+
case TokenType.CHARACTER: {
|
424
|
+
this.handler.onCharacter(this.currentCharacterToken);
|
425
|
+
break;
|
426
|
+
}
|
427
|
+
case TokenType.NULL_CHARACTER: {
|
428
|
+
this.handler.onNullCharacter(this.currentCharacterToken);
|
429
|
+
break;
|
430
|
+
}
|
431
|
+
case TokenType.WHITESPACE_CHARACTER: {
|
432
|
+
this.handler.onWhitespaceCharacter(this.currentCharacterToken);
|
433
|
+
break;
|
434
|
+
}
|
435
|
+
}
|
436
|
+
this.currentCharacterToken = null;
|
437
|
+
}
|
438
|
+
}
|
439
|
+
_emitEOFToken() {
|
440
|
+
const location = this.getCurrentLocation(0);
|
441
|
+
if (location) {
|
442
|
+
location.endLine = location.startLine;
|
443
|
+
location.endCol = location.startCol;
|
444
|
+
location.endOffset = location.startOffset;
|
445
|
+
}
|
446
|
+
this._emitCurrentCharacterToken(location);
|
447
|
+
this.handler.onEof({ type: TokenType.EOF, location });
|
448
|
+
this.active = false;
|
449
|
+
}
|
450
|
+
//Characters emission
|
451
|
+
//OPTIMIZATION: specification uses only one type of character tokens (one token per character).
|
452
|
+
//This causes a huge memory overhead and a lot of unnecessary parser loops. parse5 uses 3 groups of characters.
|
453
|
+
//If we have a sequence of characters that belong to the same group, the parser can process it
|
454
|
+
//as a single solid character token.
|
455
|
+
//So, there are 3 types of character tokens in parse5:
|
456
|
+
//1)TokenType.NULL_CHARACTER - \u0000-character sequences (e.g. '\u0000\u0000\u0000')
|
457
|
+
//2)TokenType.WHITESPACE_CHARACTER - any whitespace/new-line character sequences (e.g. '\n \r\t \f')
|
458
|
+
//3)TokenType.CHARACTER - any character sequence which don't belong to groups 1 and 2 (e.g. 'abcdef1234@@#$%^')
|
459
|
+
_appendCharToCurrentCharacterToken(type, ch) {
|
460
|
+
if (this.currentCharacterToken) {
|
461
|
+
if (this.currentCharacterToken.type !== type) {
|
462
|
+
this.currentLocation = this.getCurrentLocation(0);
|
463
|
+
this._emitCurrentCharacterToken(this.currentLocation);
|
464
|
+
this.preprocessor.dropParsedChunk();
|
465
|
+
}
|
466
|
+
else {
|
467
|
+
this.currentCharacterToken.chars += ch;
|
468
|
+
return;
|
469
|
+
}
|
470
|
+
}
|
471
|
+
this._createCharacterToken(type, ch);
|
472
|
+
}
|
473
|
+
_emitCodePoint(cp) {
|
474
|
+
const type = isWhitespace(cp)
|
475
|
+
? TokenType.WHITESPACE_CHARACTER
|
476
|
+
: cp === $.NULL
|
477
|
+
? TokenType.NULL_CHARACTER
|
478
|
+
: TokenType.CHARACTER;
|
479
|
+
this._appendCharToCurrentCharacterToken(type, String.fromCodePoint(cp));
|
480
|
+
}
|
481
|
+
//NOTE: used when we emit characters explicitly.
|
482
|
+
//This is always for non-whitespace and non-null characters, which allows us to avoid additional checks.
|
483
|
+
_emitChars(ch) {
|
484
|
+
this._appendCharToCurrentCharacterToken(TokenType.CHARACTER, ch);
|
485
|
+
}
|
486
|
+
// Character reference helpers
|
487
|
+
_matchNamedCharacterReference(cp) {
|
488
|
+
let result = null;
|
489
|
+
let excess = 0;
|
490
|
+
let withoutSemicolon = false;
|
491
|
+
for (let i = 0, current = htmlDecodeTree[0]; i >= 0; cp = this._consume()) {
|
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;
|
540
|
+
}
|
541
|
+
_isCharacterReferenceInAttribute() {
|
542
|
+
return (this.returnState === State.ATTRIBUTE_VALUE_DOUBLE_QUOTED ||
|
543
|
+
this.returnState === State.ATTRIBUTE_VALUE_SINGLE_QUOTED ||
|
544
|
+
this.returnState === State.ATTRIBUTE_VALUE_UNQUOTED);
|
545
|
+
}
|
546
|
+
_flushCodePointConsumedAsCharacterReference(cp) {
|
547
|
+
if (this._isCharacterReferenceInAttribute()) {
|
548
|
+
this.currentAttr.value += String.fromCodePoint(cp);
|
549
|
+
}
|
550
|
+
else {
|
551
|
+
this._emitCodePoint(cp);
|
552
|
+
}
|
553
|
+
}
|
554
|
+
// Calling states this way turns out to be much faster than any other approach.
|
555
|
+
_callState(cp) {
|
556
|
+
switch (this.state) {
|
557
|
+
case State.DATA: {
|
558
|
+
this._stateData(cp);
|
559
|
+
break;
|
560
|
+
}
|
561
|
+
case State.RCDATA: {
|
562
|
+
this._stateRcdata(cp);
|
563
|
+
break;
|
564
|
+
}
|
565
|
+
case State.RAWTEXT: {
|
566
|
+
this._stateRawtext(cp);
|
567
|
+
break;
|
568
|
+
}
|
569
|
+
case State.SCRIPT_DATA: {
|
570
|
+
this._stateScriptData(cp);
|
571
|
+
break;
|
572
|
+
}
|
573
|
+
case State.PLAINTEXT: {
|
574
|
+
this._statePlaintext(cp);
|
575
|
+
break;
|
576
|
+
}
|
577
|
+
case State.TAG_OPEN: {
|
578
|
+
this._stateTagOpen(cp);
|
579
|
+
break;
|
580
|
+
}
|
581
|
+
case State.END_TAG_OPEN: {
|
582
|
+
this._stateEndTagOpen(cp);
|
583
|
+
break;
|
584
|
+
}
|
585
|
+
case State.TAG_NAME: {
|
586
|
+
this._stateTagName(cp);
|
587
|
+
break;
|
588
|
+
}
|
589
|
+
case State.RCDATA_LESS_THAN_SIGN: {
|
590
|
+
this._stateRcdataLessThanSign(cp);
|
591
|
+
break;
|
592
|
+
}
|
593
|
+
case State.RCDATA_END_TAG_OPEN: {
|
594
|
+
this._stateRcdataEndTagOpen(cp);
|
595
|
+
break;
|
596
|
+
}
|
597
|
+
case State.RCDATA_END_TAG_NAME: {
|
598
|
+
this._stateRcdataEndTagName(cp);
|
599
|
+
break;
|
600
|
+
}
|
601
|
+
case State.RAWTEXT_LESS_THAN_SIGN: {
|
602
|
+
this._stateRawtextLessThanSign(cp);
|
603
|
+
break;
|
604
|
+
}
|
605
|
+
case State.RAWTEXT_END_TAG_OPEN: {
|
606
|
+
this._stateRawtextEndTagOpen(cp);
|
607
|
+
break;
|
608
|
+
}
|
609
|
+
case State.RAWTEXT_END_TAG_NAME: {
|
610
|
+
this._stateRawtextEndTagName(cp);
|
611
|
+
break;
|
612
|
+
}
|
613
|
+
case State.SCRIPT_DATA_LESS_THAN_SIGN: {
|
614
|
+
this._stateScriptDataLessThanSign(cp);
|
615
|
+
break;
|
616
|
+
}
|
617
|
+
case State.SCRIPT_DATA_END_TAG_OPEN: {
|
618
|
+
this._stateScriptDataEndTagOpen(cp);
|
619
|
+
break;
|
620
|
+
}
|
621
|
+
case State.SCRIPT_DATA_END_TAG_NAME: {
|
622
|
+
this._stateScriptDataEndTagName(cp);
|
623
|
+
break;
|
624
|
+
}
|
625
|
+
case State.SCRIPT_DATA_ESCAPE_START: {
|
626
|
+
this._stateScriptDataEscapeStart(cp);
|
627
|
+
break;
|
628
|
+
}
|
629
|
+
case State.SCRIPT_DATA_ESCAPE_START_DASH: {
|
630
|
+
this._stateScriptDataEscapeStartDash(cp);
|
631
|
+
break;
|
632
|
+
}
|
633
|
+
case State.SCRIPT_DATA_ESCAPED: {
|
634
|
+
this._stateScriptDataEscaped(cp);
|
635
|
+
break;
|
636
|
+
}
|
637
|
+
case State.SCRIPT_DATA_ESCAPED_DASH: {
|
638
|
+
this._stateScriptDataEscapedDash(cp);
|
639
|
+
break;
|
640
|
+
}
|
641
|
+
case State.SCRIPT_DATA_ESCAPED_DASH_DASH: {
|
642
|
+
this._stateScriptDataEscapedDashDash(cp);
|
643
|
+
break;
|
644
|
+
}
|
645
|
+
case State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
|
646
|
+
this._stateScriptDataEscapedLessThanSign(cp);
|
647
|
+
break;
|
648
|
+
}
|
649
|
+
case State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN: {
|
650
|
+
this._stateScriptDataEscapedEndTagOpen(cp);
|
651
|
+
break;
|
652
|
+
}
|
653
|
+
case State.SCRIPT_DATA_ESCAPED_END_TAG_NAME: {
|
654
|
+
this._stateScriptDataEscapedEndTagName(cp);
|
655
|
+
break;
|
656
|
+
}
|
657
|
+
case State.SCRIPT_DATA_DOUBLE_ESCAPE_START: {
|
658
|
+
this._stateScriptDataDoubleEscapeStart(cp);
|
659
|
+
break;
|
660
|
+
}
|
661
|
+
case State.SCRIPT_DATA_DOUBLE_ESCAPED: {
|
662
|
+
this._stateScriptDataDoubleEscaped(cp);
|
663
|
+
break;
|
664
|
+
}
|
665
|
+
case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH: {
|
666
|
+
this._stateScriptDataDoubleEscapedDash(cp);
|
667
|
+
break;
|
668
|
+
}
|
669
|
+
case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: {
|
670
|
+
this._stateScriptDataDoubleEscapedDashDash(cp);
|
671
|
+
break;
|
672
|
+
}
|
673
|
+
case State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: {
|
674
|
+
this._stateScriptDataDoubleEscapedLessThanSign(cp);
|
675
|
+
break;
|
676
|
+
}
|
677
|
+
case State.SCRIPT_DATA_DOUBLE_ESCAPE_END: {
|
678
|
+
this._stateScriptDataDoubleEscapeEnd(cp);
|
679
|
+
break;
|
680
|
+
}
|
681
|
+
case State.BEFORE_ATTRIBUTE_NAME: {
|
682
|
+
this._stateBeforeAttributeName(cp);
|
683
|
+
break;
|
684
|
+
}
|
685
|
+
case State.ATTRIBUTE_NAME: {
|
686
|
+
this._stateAttributeName(cp);
|
687
|
+
break;
|
688
|
+
}
|
689
|
+
case State.AFTER_ATTRIBUTE_NAME: {
|
690
|
+
this._stateAfterAttributeName(cp);
|
691
|
+
break;
|
692
|
+
}
|
693
|
+
case State.BEFORE_ATTRIBUTE_VALUE: {
|
694
|
+
this._stateBeforeAttributeValue(cp);
|
695
|
+
break;
|
696
|
+
}
|
697
|
+
case State.ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
|
698
|
+
this._stateAttributeValueDoubleQuoted(cp);
|
699
|
+
break;
|
700
|
+
}
|
701
|
+
case State.ATTRIBUTE_VALUE_SINGLE_QUOTED: {
|
702
|
+
this._stateAttributeValueSingleQuoted(cp);
|
703
|
+
break;
|
704
|
+
}
|
705
|
+
case State.ATTRIBUTE_VALUE_UNQUOTED: {
|
706
|
+
this._stateAttributeValueUnquoted(cp);
|
707
|
+
break;
|
708
|
+
}
|
709
|
+
case State.AFTER_ATTRIBUTE_VALUE_QUOTED: {
|
710
|
+
this._stateAfterAttributeValueQuoted(cp);
|
711
|
+
break;
|
712
|
+
}
|
713
|
+
case State.SELF_CLOSING_START_TAG: {
|
714
|
+
this._stateSelfClosingStartTag(cp);
|
715
|
+
break;
|
716
|
+
}
|
717
|
+
case State.BOGUS_COMMENT: {
|
718
|
+
this._stateBogusComment(cp);
|
719
|
+
break;
|
720
|
+
}
|
721
|
+
case State.MARKUP_DECLARATION_OPEN: {
|
722
|
+
this._stateMarkupDeclarationOpen(cp);
|
723
|
+
break;
|
724
|
+
}
|
725
|
+
case State.COMMENT_START: {
|
726
|
+
this._stateCommentStart(cp);
|
727
|
+
break;
|
728
|
+
}
|
729
|
+
case State.COMMENT_START_DASH: {
|
730
|
+
this._stateCommentStartDash(cp);
|
731
|
+
break;
|
732
|
+
}
|
733
|
+
case State.COMMENT: {
|
734
|
+
this._stateComment(cp);
|
735
|
+
break;
|
736
|
+
}
|
737
|
+
case State.COMMENT_LESS_THAN_SIGN: {
|
738
|
+
this._stateCommentLessThanSign(cp);
|
739
|
+
break;
|
740
|
+
}
|
741
|
+
case State.COMMENT_LESS_THAN_SIGN_BANG: {
|
742
|
+
this._stateCommentLessThanSignBang(cp);
|
743
|
+
break;
|
744
|
+
}
|
745
|
+
case State.COMMENT_LESS_THAN_SIGN_BANG_DASH: {
|
746
|
+
this._stateCommentLessThanSignBangDash(cp);
|
747
|
+
break;
|
748
|
+
}
|
749
|
+
case State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH: {
|
750
|
+
this._stateCommentLessThanSignBangDashDash(cp);
|
751
|
+
break;
|
752
|
+
}
|
753
|
+
case State.COMMENT_END_DASH: {
|
754
|
+
this._stateCommentEndDash(cp);
|
755
|
+
break;
|
756
|
+
}
|
757
|
+
case State.COMMENT_END: {
|
758
|
+
this._stateCommentEnd(cp);
|
759
|
+
break;
|
760
|
+
}
|
761
|
+
case State.COMMENT_END_BANG: {
|
762
|
+
this._stateCommentEndBang(cp);
|
763
|
+
break;
|
764
|
+
}
|
765
|
+
case State.DOCTYPE: {
|
766
|
+
this._stateDoctype(cp);
|
767
|
+
break;
|
768
|
+
}
|
769
|
+
case State.BEFORE_DOCTYPE_NAME: {
|
770
|
+
this._stateBeforeDoctypeName(cp);
|
771
|
+
break;
|
772
|
+
}
|
773
|
+
case State.DOCTYPE_NAME: {
|
774
|
+
this._stateDoctypeName(cp);
|
775
|
+
break;
|
776
|
+
}
|
777
|
+
case State.AFTER_DOCTYPE_NAME: {
|
778
|
+
this._stateAfterDoctypeName(cp);
|
779
|
+
break;
|
780
|
+
}
|
781
|
+
case State.AFTER_DOCTYPE_PUBLIC_KEYWORD: {
|
782
|
+
this._stateAfterDoctypePublicKeyword(cp);
|
783
|
+
break;
|
784
|
+
}
|
785
|
+
case State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
|
786
|
+
this._stateBeforeDoctypePublicIdentifier(cp);
|
787
|
+
break;
|
788
|
+
}
|
789
|
+
case State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: {
|
790
|
+
this._stateDoctypePublicIdentifierDoubleQuoted(cp);
|
791
|
+
break;
|
792
|
+
}
|
793
|
+
case State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
|
794
|
+
this._stateDoctypePublicIdentifierSingleQuoted(cp);
|
795
|
+
break;
|
796
|
+
}
|
797
|
+
case State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER: {
|
798
|
+
this._stateAfterDoctypePublicIdentifier(cp);
|
799
|
+
break;
|
800
|
+
}
|
801
|
+
case State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
|
802
|
+
this._stateBetweenDoctypePublicAndSystemIdentifiers(cp);
|
803
|
+
break;
|
804
|
+
}
|
805
|
+
case State.AFTER_DOCTYPE_SYSTEM_KEYWORD: {
|
806
|
+
this._stateAfterDoctypeSystemKeyword(cp);
|
807
|
+
break;
|
808
|
+
}
|
809
|
+
case State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: {
|
810
|
+
this._stateBeforeDoctypeSystemIdentifier(cp);
|
811
|
+
break;
|
812
|
+
}
|
813
|
+
case State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: {
|
814
|
+
this._stateDoctypeSystemIdentifierDoubleQuoted(cp);
|
815
|
+
break;
|
816
|
+
}
|
817
|
+
case State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
|
818
|
+
this._stateDoctypeSystemIdentifierSingleQuoted(cp);
|
819
|
+
break;
|
820
|
+
}
|
821
|
+
case State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
|
822
|
+
this._stateAfterDoctypeSystemIdentifier(cp);
|
823
|
+
break;
|
824
|
+
}
|
825
|
+
case State.BOGUS_DOCTYPE: {
|
826
|
+
this._stateBogusDoctype(cp);
|
827
|
+
break;
|
828
|
+
}
|
829
|
+
case State.CDATA_SECTION: {
|
830
|
+
this._stateCdataSection(cp);
|
831
|
+
break;
|
832
|
+
}
|
833
|
+
case State.CDATA_SECTION_BRACKET: {
|
834
|
+
this._stateCdataSectionBracket(cp);
|
835
|
+
break;
|
836
|
+
}
|
837
|
+
case State.CDATA_SECTION_END: {
|
838
|
+
this._stateCdataSectionEnd(cp);
|
839
|
+
break;
|
840
|
+
}
|
841
|
+
case State.CHARACTER_REFERENCE: {
|
842
|
+
this._stateCharacterReference(cp);
|
843
|
+
break;
|
844
|
+
}
|
845
|
+
case State.NAMED_CHARACTER_REFERENCE: {
|
846
|
+
this._stateNamedCharacterReference(cp);
|
847
|
+
break;
|
848
|
+
}
|
849
|
+
case State.AMBIGUOUS_AMPERSAND: {
|
850
|
+
this._stateAmbiguousAmpersand(cp);
|
851
|
+
break;
|
852
|
+
}
|
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
|
+
default: {
|
874
|
+
throw new Error('Unknown state');
|
875
|
+
}
|
876
|
+
}
|
877
|
+
}
|
878
|
+
// State machine
|
879
|
+
// Data state
|
880
|
+
//------------------------------------------------------------------
|
881
|
+
_stateData(cp) {
|
882
|
+
switch (cp) {
|
883
|
+
case $.LESS_THAN_SIGN: {
|
884
|
+
this.state = State.TAG_OPEN;
|
885
|
+
break;
|
886
|
+
}
|
887
|
+
case $.AMPERSAND: {
|
888
|
+
this.returnState = State.DATA;
|
889
|
+
this.state = State.CHARACTER_REFERENCE;
|
890
|
+
break;
|
891
|
+
}
|
892
|
+
case $.NULL: {
|
893
|
+
this._err(ERR.unexpectedNullCharacter);
|
894
|
+
this._emitCodePoint(cp);
|
895
|
+
break;
|
896
|
+
}
|
897
|
+
case $.EOF: {
|
898
|
+
this._emitEOFToken();
|
899
|
+
break;
|
900
|
+
}
|
901
|
+
default: {
|
902
|
+
this._emitCodePoint(cp);
|
903
|
+
}
|
904
|
+
}
|
905
|
+
}
|
906
|
+
// RCDATA state
|
907
|
+
//------------------------------------------------------------------
|
908
|
+
_stateRcdata(cp) {
|
909
|
+
switch (cp) {
|
910
|
+
case $.AMPERSAND: {
|
911
|
+
this.returnState = State.RCDATA;
|
912
|
+
this.state = State.CHARACTER_REFERENCE;
|
913
|
+
break;
|
914
|
+
}
|
915
|
+
case $.LESS_THAN_SIGN: {
|
916
|
+
this.state = State.RCDATA_LESS_THAN_SIGN;
|
917
|
+
break;
|
918
|
+
}
|
919
|
+
case $.NULL: {
|
920
|
+
this._err(ERR.unexpectedNullCharacter);
|
921
|
+
this._emitChars(REPLACEMENT_CHARACTER);
|
922
|
+
break;
|
923
|
+
}
|
924
|
+
case $.EOF: {
|
925
|
+
this._emitEOFToken();
|
926
|
+
break;
|
927
|
+
}
|
928
|
+
default: {
|
929
|
+
this._emitCodePoint(cp);
|
930
|
+
}
|
931
|
+
}
|
932
|
+
}
|
933
|
+
// RAWTEXT state
|
934
|
+
//------------------------------------------------------------------
|
935
|
+
_stateRawtext(cp) {
|
936
|
+
switch (cp) {
|
937
|
+
case $.LESS_THAN_SIGN: {
|
938
|
+
this.state = State.RAWTEXT_LESS_THAN_SIGN;
|
939
|
+
break;
|
940
|
+
}
|
941
|
+
case $.NULL: {
|
942
|
+
this._err(ERR.unexpectedNullCharacter);
|
943
|
+
this._emitChars(REPLACEMENT_CHARACTER);
|
944
|
+
break;
|
945
|
+
}
|
946
|
+
case $.EOF: {
|
947
|
+
this._emitEOFToken();
|
948
|
+
break;
|
949
|
+
}
|
950
|
+
default: {
|
951
|
+
this._emitCodePoint(cp);
|
952
|
+
}
|
953
|
+
}
|
954
|
+
}
|
955
|
+
// Script data state
|
956
|
+
//------------------------------------------------------------------
|
957
|
+
_stateScriptData(cp) {
|
958
|
+
switch (cp) {
|
959
|
+
case $.LESS_THAN_SIGN: {
|
960
|
+
this.state = State.SCRIPT_DATA_LESS_THAN_SIGN;
|
961
|
+
break;
|
962
|
+
}
|
963
|
+
case $.NULL: {
|
964
|
+
this._err(ERR.unexpectedNullCharacter);
|
965
|
+
this._emitChars(REPLACEMENT_CHARACTER);
|
966
|
+
break;
|
967
|
+
}
|
968
|
+
case $.EOF: {
|
969
|
+
this._emitEOFToken();
|
970
|
+
break;
|
971
|
+
}
|
972
|
+
default: {
|
973
|
+
this._emitCodePoint(cp);
|
974
|
+
}
|
975
|
+
}
|
976
|
+
}
|
977
|
+
// PLAINTEXT state
|
978
|
+
//------------------------------------------------------------------
|
979
|
+
_statePlaintext(cp) {
|
980
|
+
switch (cp) {
|
981
|
+
case $.NULL: {
|
982
|
+
this._err(ERR.unexpectedNullCharacter);
|
983
|
+
this._emitChars(REPLACEMENT_CHARACTER);
|
984
|
+
break;
|
985
|
+
}
|
986
|
+
case $.EOF: {
|
987
|
+
this._emitEOFToken();
|
988
|
+
break;
|
989
|
+
}
|
990
|
+
default: {
|
991
|
+
this._emitCodePoint(cp);
|
992
|
+
}
|
993
|
+
}
|
994
|
+
}
|
995
|
+
// Tag open state
|
996
|
+
//------------------------------------------------------------------
|
997
|
+
_stateTagOpen(cp) {
|
998
|
+
if (isAsciiLetter(cp)) {
|
999
|
+
this._createStartTagToken();
|
1000
|
+
this.state = State.TAG_NAME;
|
1001
|
+
this._stateTagName(cp);
|
1002
|
+
}
|
1003
|
+
else
|
1004
|
+
switch (cp) {
|
1005
|
+
case $.EXCLAMATION_MARK: {
|
1006
|
+
this.state = State.MARKUP_DECLARATION_OPEN;
|
1007
|
+
break;
|
1008
|
+
}
|
1009
|
+
case $.SOLIDUS: {
|
1010
|
+
this.state = State.END_TAG_OPEN;
|
1011
|
+
break;
|
1012
|
+
}
|
1013
|
+
case $.QUESTION_MARK: {
|
1014
|
+
this._err(ERR.unexpectedQuestionMarkInsteadOfTagName);
|
1015
|
+
this._createCommentToken(1);
|
1016
|
+
this.state = State.BOGUS_COMMENT;
|
1017
|
+
this._stateBogusComment(cp);
|
1018
|
+
break;
|
1019
|
+
}
|
1020
|
+
case $.EOF: {
|
1021
|
+
this._err(ERR.eofBeforeTagName);
|
1022
|
+
this._emitChars('<');
|
1023
|
+
this._emitEOFToken();
|
1024
|
+
break;
|
1025
|
+
}
|
1026
|
+
default: {
|
1027
|
+
this._err(ERR.invalidFirstCharacterOfTagName);
|
1028
|
+
this._emitChars('<');
|
1029
|
+
this.state = State.DATA;
|
1030
|
+
this._stateData(cp);
|
1031
|
+
}
|
1032
|
+
}
|
1033
|
+
}
|
1034
|
+
// End tag open state
|
1035
|
+
//------------------------------------------------------------------
|
1036
|
+
_stateEndTagOpen(cp) {
|
1037
|
+
if (isAsciiLetter(cp)) {
|
1038
|
+
this._createEndTagToken();
|
1039
|
+
this.state = State.TAG_NAME;
|
1040
|
+
this._stateTagName(cp);
|
1041
|
+
}
|
1042
|
+
else
|
1043
|
+
switch (cp) {
|
1044
|
+
case $.GREATER_THAN_SIGN: {
|
1045
|
+
this._err(ERR.missingEndTagName);
|
1046
|
+
this.state = State.DATA;
|
1047
|
+
break;
|
1048
|
+
}
|
1049
|
+
case $.EOF: {
|
1050
|
+
this._err(ERR.eofBeforeTagName);
|
1051
|
+
this._emitChars('</');
|
1052
|
+
this._emitEOFToken();
|
1053
|
+
break;
|
1054
|
+
}
|
1055
|
+
default: {
|
1056
|
+
this._err(ERR.invalidFirstCharacterOfTagName);
|
1057
|
+
this._createCommentToken(2);
|
1058
|
+
this.state = State.BOGUS_COMMENT;
|
1059
|
+
this._stateBogusComment(cp);
|
1060
|
+
}
|
1061
|
+
}
|
1062
|
+
}
|
1063
|
+
// Tag name state
|
1064
|
+
//------------------------------------------------------------------
|
1065
|
+
_stateTagName(cp) {
|
1066
|
+
const token = this.currentToken;
|
1067
|
+
switch (cp) {
|
1068
|
+
case $.SPACE:
|
1069
|
+
case $.LINE_FEED:
|
1070
|
+
case $.TABULATION:
|
1071
|
+
case $.FORM_FEED: {
|
1072
|
+
this.state = State.BEFORE_ATTRIBUTE_NAME;
|
1073
|
+
break;
|
1074
|
+
}
|
1075
|
+
case $.SOLIDUS: {
|
1076
|
+
this.state = State.SELF_CLOSING_START_TAG;
|
1077
|
+
break;
|
1078
|
+
}
|
1079
|
+
case $.GREATER_THAN_SIGN: {
|
1080
|
+
this.state = State.DATA;
|
1081
|
+
this.emitCurrentTagToken();
|
1082
|
+
break;
|
1083
|
+
}
|
1084
|
+
case $.NULL: {
|
1085
|
+
this._err(ERR.unexpectedNullCharacter);
|
1086
|
+
token.tagName += REPLACEMENT_CHARACTER;
|
1087
|
+
break;
|
1088
|
+
}
|
1089
|
+
case $.EOF: {
|
1090
|
+
this._err(ERR.eofInTag);
|
1091
|
+
this._emitEOFToken();
|
1092
|
+
break;
|
1093
|
+
}
|
1094
|
+
default: {
|
1095
|
+
token.tagName += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
|
1096
|
+
}
|
1097
|
+
}
|
1098
|
+
}
|
1099
|
+
// RCDATA less-than sign state
|
1100
|
+
//------------------------------------------------------------------
|
1101
|
+
_stateRcdataLessThanSign(cp) {
|
1102
|
+
if (cp === $.SOLIDUS) {
|
1103
|
+
this.state = State.RCDATA_END_TAG_OPEN;
|
1104
|
+
}
|
1105
|
+
else {
|
1106
|
+
this._emitChars('<');
|
1107
|
+
this.state = State.RCDATA;
|
1108
|
+
this._stateRcdata(cp);
|
1109
|
+
}
|
1110
|
+
}
|
1111
|
+
// RCDATA end tag open state
|
1112
|
+
//------------------------------------------------------------------
|
1113
|
+
_stateRcdataEndTagOpen(cp) {
|
1114
|
+
if (isAsciiLetter(cp)) {
|
1115
|
+
this.state = State.RCDATA_END_TAG_NAME;
|
1116
|
+
this._stateRcdataEndTagName(cp);
|
1117
|
+
}
|
1118
|
+
else {
|
1119
|
+
this._emitChars('</');
|
1120
|
+
this.state = State.RCDATA;
|
1121
|
+
this._stateRcdata(cp);
|
1122
|
+
}
|
1123
|
+
}
|
1124
|
+
handleSpecialEndTag(_cp) {
|
1125
|
+
if (!this.preprocessor.startsWith(this.lastStartTagName, false)) {
|
1126
|
+
return !this._ensureHibernation();
|
1127
|
+
}
|
1128
|
+
this._createEndTagToken();
|
1129
|
+
const token = this.currentToken;
|
1130
|
+
token.tagName = this.lastStartTagName;
|
1131
|
+
const cp = this.preprocessor.peek(this.lastStartTagName.length);
|
1132
|
+
switch (cp) {
|
1133
|
+
case $.SPACE:
|
1134
|
+
case $.LINE_FEED:
|
1135
|
+
case $.TABULATION:
|
1136
|
+
case $.FORM_FEED: {
|
1137
|
+
this._advanceBy(this.lastStartTagName.length);
|
1138
|
+
this.state = State.BEFORE_ATTRIBUTE_NAME;
|
1139
|
+
return false;
|
1140
|
+
}
|
1141
|
+
case $.SOLIDUS: {
|
1142
|
+
this._advanceBy(this.lastStartTagName.length);
|
1143
|
+
this.state = State.SELF_CLOSING_START_TAG;
|
1144
|
+
return false;
|
1145
|
+
}
|
1146
|
+
case $.GREATER_THAN_SIGN: {
|
1147
|
+
this._advanceBy(this.lastStartTagName.length);
|
1148
|
+
this.emitCurrentTagToken();
|
1149
|
+
this.state = State.DATA;
|
1150
|
+
return false;
|
1151
|
+
}
|
1152
|
+
default: {
|
1153
|
+
return !this._ensureHibernation();
|
1154
|
+
}
|
1155
|
+
}
|
1156
|
+
}
|
1157
|
+
// RCDATA end tag name state
|
1158
|
+
//------------------------------------------------------------------
|
1159
|
+
_stateRcdataEndTagName(cp) {
|
1160
|
+
if (this.handleSpecialEndTag(cp)) {
|
1161
|
+
this._emitChars('</');
|
1162
|
+
this.state = State.RCDATA;
|
1163
|
+
this._stateRcdata(cp);
|
1164
|
+
}
|
1165
|
+
}
|
1166
|
+
// RAWTEXT less-than sign state
|
1167
|
+
//------------------------------------------------------------------
|
1168
|
+
_stateRawtextLessThanSign(cp) {
|
1169
|
+
if (cp === $.SOLIDUS) {
|
1170
|
+
this.state = State.RAWTEXT_END_TAG_OPEN;
|
1171
|
+
}
|
1172
|
+
else {
|
1173
|
+
this._emitChars('<');
|
1174
|
+
this.state = State.RAWTEXT;
|
1175
|
+
this._stateRawtext(cp);
|
1176
|
+
}
|
1177
|
+
}
|
1178
|
+
// RAWTEXT end tag open state
|
1179
|
+
//------------------------------------------------------------------
|
1180
|
+
_stateRawtextEndTagOpen(cp) {
|
1181
|
+
if (isAsciiLetter(cp)) {
|
1182
|
+
this.state = State.RAWTEXT_END_TAG_NAME;
|
1183
|
+
this._stateRawtextEndTagName(cp);
|
1184
|
+
}
|
1185
|
+
else {
|
1186
|
+
this._emitChars('</');
|
1187
|
+
this.state = State.RAWTEXT;
|
1188
|
+
this._stateRawtext(cp);
|
1189
|
+
}
|
1190
|
+
}
|
1191
|
+
// RAWTEXT end tag name state
|
1192
|
+
//------------------------------------------------------------------
|
1193
|
+
_stateRawtextEndTagName(cp) {
|
1194
|
+
if (this.handleSpecialEndTag(cp)) {
|
1195
|
+
this._emitChars('</');
|
1196
|
+
this.state = State.RAWTEXT;
|
1197
|
+
this._stateRawtext(cp);
|
1198
|
+
}
|
1199
|
+
}
|
1200
|
+
// Script data less-than sign state
|
1201
|
+
//------------------------------------------------------------------
|
1202
|
+
_stateScriptDataLessThanSign(cp) {
|
1203
|
+
switch (cp) {
|
1204
|
+
case $.SOLIDUS: {
|
1205
|
+
this.state = State.SCRIPT_DATA_END_TAG_OPEN;
|
1206
|
+
break;
|
1207
|
+
}
|
1208
|
+
case $.EXCLAMATION_MARK: {
|
1209
|
+
this.state = State.SCRIPT_DATA_ESCAPE_START;
|
1210
|
+
this._emitChars('<!');
|
1211
|
+
break;
|
1212
|
+
}
|
1213
|
+
default: {
|
1214
|
+
this._emitChars('<');
|
1215
|
+
this.state = State.SCRIPT_DATA;
|
1216
|
+
this._stateScriptData(cp);
|
1217
|
+
}
|
1218
|
+
}
|
1219
|
+
}
|
1220
|
+
// Script data end tag open state
|
1221
|
+
//------------------------------------------------------------------
|
1222
|
+
_stateScriptDataEndTagOpen(cp) {
|
1223
|
+
if (isAsciiLetter(cp)) {
|
1224
|
+
this.state = State.SCRIPT_DATA_END_TAG_NAME;
|
1225
|
+
this._stateScriptDataEndTagName(cp);
|
1226
|
+
}
|
1227
|
+
else {
|
1228
|
+
this._emitChars('</');
|
1229
|
+
this.state = State.SCRIPT_DATA;
|
1230
|
+
this._stateScriptData(cp);
|
1231
|
+
}
|
1232
|
+
}
|
1233
|
+
// Script data end tag name state
|
1234
|
+
//------------------------------------------------------------------
|
1235
|
+
_stateScriptDataEndTagName(cp) {
|
1236
|
+
if (this.handleSpecialEndTag(cp)) {
|
1237
|
+
this._emitChars('</');
|
1238
|
+
this.state = State.SCRIPT_DATA;
|
1239
|
+
this._stateScriptData(cp);
|
1240
|
+
}
|
1241
|
+
}
|
1242
|
+
// Script data escape start state
|
1243
|
+
//------------------------------------------------------------------
|
1244
|
+
_stateScriptDataEscapeStart(cp) {
|
1245
|
+
if (cp === $.HYPHEN_MINUS) {
|
1246
|
+
this.state = State.SCRIPT_DATA_ESCAPE_START_DASH;
|
1247
|
+
this._emitChars('-');
|
1248
|
+
}
|
1249
|
+
else {
|
1250
|
+
this.state = State.SCRIPT_DATA;
|
1251
|
+
this._stateScriptData(cp);
|
1252
|
+
}
|
1253
|
+
}
|
1254
|
+
// Script data escape start dash state
|
1255
|
+
//------------------------------------------------------------------
|
1256
|
+
_stateScriptDataEscapeStartDash(cp) {
|
1257
|
+
if (cp === $.HYPHEN_MINUS) {
|
1258
|
+
this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
|
1259
|
+
this._emitChars('-');
|
1260
|
+
}
|
1261
|
+
else {
|
1262
|
+
this.state = State.SCRIPT_DATA;
|
1263
|
+
this._stateScriptData(cp);
|
1264
|
+
}
|
1265
|
+
}
|
1266
|
+
// Script data escaped state
|
1267
|
+
//------------------------------------------------------------------
|
1268
|
+
_stateScriptDataEscaped(cp) {
|
1269
|
+
switch (cp) {
|
1270
|
+
case $.HYPHEN_MINUS: {
|
1271
|
+
this.state = State.SCRIPT_DATA_ESCAPED_DASH;
|
1272
|
+
this._emitChars('-');
|
1273
|
+
break;
|
1274
|
+
}
|
1275
|
+
case $.LESS_THAN_SIGN: {
|
1276
|
+
this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
|
1277
|
+
break;
|
1278
|
+
}
|
1279
|
+
case $.NULL: {
|
1280
|
+
this._err(ERR.unexpectedNullCharacter);
|
1281
|
+
this._emitChars(REPLACEMENT_CHARACTER);
|
1282
|
+
break;
|
1283
|
+
}
|
1284
|
+
case $.EOF: {
|
1285
|
+
this._err(ERR.eofInScriptHtmlCommentLikeText);
|
1286
|
+
this._emitEOFToken();
|
1287
|
+
break;
|
1288
|
+
}
|
1289
|
+
default: {
|
1290
|
+
this._emitCodePoint(cp);
|
1291
|
+
}
|
1292
|
+
}
|
1293
|
+
}
|
1294
|
+
// Script data escaped dash state
|
1295
|
+
//------------------------------------------------------------------
|
1296
|
+
_stateScriptDataEscapedDash(cp) {
|
1297
|
+
switch (cp) {
|
1298
|
+
case $.HYPHEN_MINUS: {
|
1299
|
+
this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
|
1300
|
+
this._emitChars('-');
|
1301
|
+
break;
|
1302
|
+
}
|
1303
|
+
case $.LESS_THAN_SIGN: {
|
1304
|
+
this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
|
1305
|
+
break;
|
1306
|
+
}
|
1307
|
+
case $.NULL: {
|
1308
|
+
this._err(ERR.unexpectedNullCharacter);
|
1309
|
+
this.state = State.SCRIPT_DATA_ESCAPED;
|
1310
|
+
this._emitChars(REPLACEMENT_CHARACTER);
|
1311
|
+
break;
|
1312
|
+
}
|
1313
|
+
case $.EOF: {
|
1314
|
+
this._err(ERR.eofInScriptHtmlCommentLikeText);
|
1315
|
+
this._emitEOFToken();
|
1316
|
+
break;
|
1317
|
+
}
|
1318
|
+
default: {
|
1319
|
+
this.state = State.SCRIPT_DATA_ESCAPED;
|
1320
|
+
this._emitCodePoint(cp);
|
1321
|
+
}
|
1322
|
+
}
|
1323
|
+
}
|
1324
|
+
// Script data escaped dash dash state
|
1325
|
+
//------------------------------------------------------------------
|
1326
|
+
_stateScriptDataEscapedDashDash(cp) {
|
1327
|
+
switch (cp) {
|
1328
|
+
case $.HYPHEN_MINUS: {
|
1329
|
+
this._emitChars('-');
|
1330
|
+
break;
|
1331
|
+
}
|
1332
|
+
case $.LESS_THAN_SIGN: {
|
1333
|
+
this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
|
1334
|
+
break;
|
1335
|
+
}
|
1336
|
+
case $.GREATER_THAN_SIGN: {
|
1337
|
+
this.state = State.SCRIPT_DATA;
|
1338
|
+
this._emitChars('>');
|
1339
|
+
break;
|
1340
|
+
}
|
1341
|
+
case $.NULL: {
|
1342
|
+
this._err(ERR.unexpectedNullCharacter);
|
1343
|
+
this.state = State.SCRIPT_DATA_ESCAPED;
|
1344
|
+
this._emitChars(REPLACEMENT_CHARACTER);
|
1345
|
+
break;
|
1346
|
+
}
|
1347
|
+
case $.EOF: {
|
1348
|
+
this._err(ERR.eofInScriptHtmlCommentLikeText);
|
1349
|
+
this._emitEOFToken();
|
1350
|
+
break;
|
1351
|
+
}
|
1352
|
+
default: {
|
1353
|
+
this.state = State.SCRIPT_DATA_ESCAPED;
|
1354
|
+
this._emitCodePoint(cp);
|
1355
|
+
}
|
1356
|
+
}
|
1357
|
+
}
|
1358
|
+
// Script data escaped less-than sign state
|
1359
|
+
//------------------------------------------------------------------
|
1360
|
+
_stateScriptDataEscapedLessThanSign(cp) {
|
1361
|
+
if (cp === $.SOLIDUS) {
|
1362
|
+
this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN;
|
1363
|
+
}
|
1364
|
+
else if (isAsciiLetter(cp)) {
|
1365
|
+
this._emitChars('<');
|
1366
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_START;
|
1367
|
+
this._stateScriptDataDoubleEscapeStart(cp);
|
1368
|
+
}
|
1369
|
+
else {
|
1370
|
+
this._emitChars('<');
|
1371
|
+
this.state = State.SCRIPT_DATA_ESCAPED;
|
1372
|
+
this._stateScriptDataEscaped(cp);
|
1373
|
+
}
|
1374
|
+
}
|
1375
|
+
// Script data escaped end tag open state
|
1376
|
+
//------------------------------------------------------------------
|
1377
|
+
_stateScriptDataEscapedEndTagOpen(cp) {
|
1378
|
+
if (isAsciiLetter(cp)) {
|
1379
|
+
this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_NAME;
|
1380
|
+
this._stateScriptDataEscapedEndTagName(cp);
|
1381
|
+
}
|
1382
|
+
else {
|
1383
|
+
this._emitChars('</');
|
1384
|
+
this.state = State.SCRIPT_DATA_ESCAPED;
|
1385
|
+
this._stateScriptDataEscaped(cp);
|
1386
|
+
}
|
1387
|
+
}
|
1388
|
+
// Script data escaped end tag name state
|
1389
|
+
//------------------------------------------------------------------
|
1390
|
+
_stateScriptDataEscapedEndTagName(cp) {
|
1391
|
+
if (this.handleSpecialEndTag(cp)) {
|
1392
|
+
this._emitChars('</');
|
1393
|
+
this.state = State.SCRIPT_DATA_ESCAPED;
|
1394
|
+
this._stateScriptDataEscaped(cp);
|
1395
|
+
}
|
1396
|
+
}
|
1397
|
+
// Script data double escape start state
|
1398
|
+
//------------------------------------------------------------------
|
1399
|
+
_stateScriptDataDoubleEscapeStart(cp) {
|
1400
|
+
if (this.preprocessor.startsWith($$.SCRIPT, false) &&
|
1401
|
+
isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek($$.SCRIPT.length))) {
|
1402
|
+
this._emitCodePoint(cp);
|
1403
|
+
for (let i = 0; i < $$.SCRIPT.length; i++) {
|
1404
|
+
this._emitCodePoint(this._consume());
|
1405
|
+
}
|
1406
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
|
1407
|
+
}
|
1408
|
+
else if (!this._ensureHibernation()) {
|
1409
|
+
this.state = State.SCRIPT_DATA_ESCAPED;
|
1410
|
+
this._stateScriptDataEscaped(cp);
|
1411
|
+
}
|
1412
|
+
}
|
1413
|
+
// Script data double escaped state
|
1414
|
+
//------------------------------------------------------------------
|
1415
|
+
_stateScriptDataDoubleEscaped(cp) {
|
1416
|
+
switch (cp) {
|
1417
|
+
case $.HYPHEN_MINUS: {
|
1418
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH;
|
1419
|
+
this._emitChars('-');
|
1420
|
+
break;
|
1421
|
+
}
|
1422
|
+
case $.LESS_THAN_SIGN: {
|
1423
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
|
1424
|
+
this._emitChars('<');
|
1425
|
+
break;
|
1426
|
+
}
|
1427
|
+
case $.NULL: {
|
1428
|
+
this._err(ERR.unexpectedNullCharacter);
|
1429
|
+
this._emitChars(REPLACEMENT_CHARACTER);
|
1430
|
+
break;
|
1431
|
+
}
|
1432
|
+
case $.EOF: {
|
1433
|
+
this._err(ERR.eofInScriptHtmlCommentLikeText);
|
1434
|
+
this._emitEOFToken();
|
1435
|
+
break;
|
1436
|
+
}
|
1437
|
+
default: {
|
1438
|
+
this._emitCodePoint(cp);
|
1439
|
+
}
|
1440
|
+
}
|
1441
|
+
}
|
1442
|
+
// Script data double escaped dash state
|
1443
|
+
//------------------------------------------------------------------
|
1444
|
+
_stateScriptDataDoubleEscapedDash(cp) {
|
1445
|
+
switch (cp) {
|
1446
|
+
case $.HYPHEN_MINUS: {
|
1447
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH;
|
1448
|
+
this._emitChars('-');
|
1449
|
+
break;
|
1450
|
+
}
|
1451
|
+
case $.LESS_THAN_SIGN: {
|
1452
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
|
1453
|
+
this._emitChars('<');
|
1454
|
+
break;
|
1455
|
+
}
|
1456
|
+
case $.NULL: {
|
1457
|
+
this._err(ERR.unexpectedNullCharacter);
|
1458
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
|
1459
|
+
this._emitChars(REPLACEMENT_CHARACTER);
|
1460
|
+
break;
|
1461
|
+
}
|
1462
|
+
case $.EOF: {
|
1463
|
+
this._err(ERR.eofInScriptHtmlCommentLikeText);
|
1464
|
+
this._emitEOFToken();
|
1465
|
+
break;
|
1466
|
+
}
|
1467
|
+
default: {
|
1468
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
|
1469
|
+
this._emitCodePoint(cp);
|
1470
|
+
}
|
1471
|
+
}
|
1472
|
+
}
|
1473
|
+
// Script data double escaped dash dash state
|
1474
|
+
//------------------------------------------------------------------
|
1475
|
+
_stateScriptDataDoubleEscapedDashDash(cp) {
|
1476
|
+
switch (cp) {
|
1477
|
+
case $.HYPHEN_MINUS: {
|
1478
|
+
this._emitChars('-');
|
1479
|
+
break;
|
1480
|
+
}
|
1481
|
+
case $.LESS_THAN_SIGN: {
|
1482
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
|
1483
|
+
this._emitChars('<');
|
1484
|
+
break;
|
1485
|
+
}
|
1486
|
+
case $.GREATER_THAN_SIGN: {
|
1487
|
+
this.state = State.SCRIPT_DATA;
|
1488
|
+
this._emitChars('>');
|
1489
|
+
break;
|
1490
|
+
}
|
1491
|
+
case $.NULL: {
|
1492
|
+
this._err(ERR.unexpectedNullCharacter);
|
1493
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
|
1494
|
+
this._emitChars(REPLACEMENT_CHARACTER);
|
1495
|
+
break;
|
1496
|
+
}
|
1497
|
+
case $.EOF: {
|
1498
|
+
this._err(ERR.eofInScriptHtmlCommentLikeText);
|
1499
|
+
this._emitEOFToken();
|
1500
|
+
break;
|
1501
|
+
}
|
1502
|
+
default: {
|
1503
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
|
1504
|
+
this._emitCodePoint(cp);
|
1505
|
+
}
|
1506
|
+
}
|
1507
|
+
}
|
1508
|
+
// Script data double escaped less-than sign state
|
1509
|
+
//------------------------------------------------------------------
|
1510
|
+
_stateScriptDataDoubleEscapedLessThanSign(cp) {
|
1511
|
+
if (cp === $.SOLIDUS) {
|
1512
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_END;
|
1513
|
+
this._emitChars('/');
|
1514
|
+
}
|
1515
|
+
else {
|
1516
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
|
1517
|
+
this._stateScriptDataDoubleEscaped(cp);
|
1518
|
+
}
|
1519
|
+
}
|
1520
|
+
// Script data double escape end state
|
1521
|
+
//------------------------------------------------------------------
|
1522
|
+
_stateScriptDataDoubleEscapeEnd(cp) {
|
1523
|
+
if (this.preprocessor.startsWith($$.SCRIPT, false) &&
|
1524
|
+
isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek($$.SCRIPT.length))) {
|
1525
|
+
this._emitCodePoint(cp);
|
1526
|
+
for (let i = 0; i < $$.SCRIPT.length; i++) {
|
1527
|
+
this._emitCodePoint(this._consume());
|
1528
|
+
}
|
1529
|
+
this.state = State.SCRIPT_DATA_ESCAPED;
|
1530
|
+
}
|
1531
|
+
else if (!this._ensureHibernation()) {
|
1532
|
+
this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
|
1533
|
+
this._stateScriptDataDoubleEscaped(cp);
|
1534
|
+
}
|
1535
|
+
}
|
1536
|
+
// Before attribute name state
|
1537
|
+
//------------------------------------------------------------------
|
1538
|
+
_stateBeforeAttributeName(cp) {
|
1539
|
+
switch (cp) {
|
1540
|
+
case $.SPACE:
|
1541
|
+
case $.LINE_FEED:
|
1542
|
+
case $.TABULATION:
|
1543
|
+
case $.FORM_FEED: {
|
1544
|
+
// Ignore whitespace
|
1545
|
+
break;
|
1546
|
+
}
|
1547
|
+
case $.SOLIDUS:
|
1548
|
+
case $.GREATER_THAN_SIGN:
|
1549
|
+
case $.EOF: {
|
1550
|
+
this.state = State.AFTER_ATTRIBUTE_NAME;
|
1551
|
+
this._stateAfterAttributeName(cp);
|
1552
|
+
break;
|
1553
|
+
}
|
1554
|
+
case $.EQUALS_SIGN: {
|
1555
|
+
this._err(ERR.unexpectedEqualsSignBeforeAttributeName);
|
1556
|
+
this._createAttr('=');
|
1557
|
+
this.state = State.ATTRIBUTE_NAME;
|
1558
|
+
break;
|
1559
|
+
}
|
1560
|
+
default: {
|
1561
|
+
this._createAttr('');
|
1562
|
+
this.state = State.ATTRIBUTE_NAME;
|
1563
|
+
this._stateAttributeName(cp);
|
1564
|
+
}
|
1565
|
+
}
|
1566
|
+
}
|
1567
|
+
// Attribute name state
|
1568
|
+
//------------------------------------------------------------------
|
1569
|
+
_stateAttributeName(cp) {
|
1570
|
+
switch (cp) {
|
1571
|
+
case $.SPACE:
|
1572
|
+
case $.LINE_FEED:
|
1573
|
+
case $.TABULATION:
|
1574
|
+
case $.FORM_FEED:
|
1575
|
+
case $.SOLIDUS:
|
1576
|
+
case $.GREATER_THAN_SIGN:
|
1577
|
+
case $.EOF: {
|
1578
|
+
this._leaveAttrName();
|
1579
|
+
this.state = State.AFTER_ATTRIBUTE_NAME;
|
1580
|
+
this._stateAfterAttributeName(cp);
|
1581
|
+
break;
|
1582
|
+
}
|
1583
|
+
case $.EQUALS_SIGN: {
|
1584
|
+
this._leaveAttrName();
|
1585
|
+
this.state = State.BEFORE_ATTRIBUTE_VALUE;
|
1586
|
+
break;
|
1587
|
+
}
|
1588
|
+
case $.QUOTATION_MARK:
|
1589
|
+
case $.APOSTROPHE:
|
1590
|
+
case $.LESS_THAN_SIGN: {
|
1591
|
+
this._err(ERR.unexpectedCharacterInAttributeName);
|
1592
|
+
this.currentAttr.name += String.fromCodePoint(cp);
|
1593
|
+
break;
|
1594
|
+
}
|
1595
|
+
case $.NULL: {
|
1596
|
+
this._err(ERR.unexpectedNullCharacter);
|
1597
|
+
this.currentAttr.name += REPLACEMENT_CHARACTER;
|
1598
|
+
break;
|
1599
|
+
}
|
1600
|
+
default: {
|
1601
|
+
this.currentAttr.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
|
1602
|
+
}
|
1603
|
+
}
|
1604
|
+
}
|
1605
|
+
// After attribute name state
|
1606
|
+
//------------------------------------------------------------------
|
1607
|
+
_stateAfterAttributeName(cp) {
|
1608
|
+
switch (cp) {
|
1609
|
+
case $.SPACE:
|
1610
|
+
case $.LINE_FEED:
|
1611
|
+
case $.TABULATION:
|
1612
|
+
case $.FORM_FEED: {
|
1613
|
+
// Ignore whitespace
|
1614
|
+
break;
|
1615
|
+
}
|
1616
|
+
case $.SOLIDUS: {
|
1617
|
+
this.state = State.SELF_CLOSING_START_TAG;
|
1618
|
+
break;
|
1619
|
+
}
|
1620
|
+
case $.EQUALS_SIGN: {
|
1621
|
+
this.state = State.BEFORE_ATTRIBUTE_VALUE;
|
1622
|
+
break;
|
1623
|
+
}
|
1624
|
+
case $.GREATER_THAN_SIGN: {
|
1625
|
+
this.state = State.DATA;
|
1626
|
+
this.emitCurrentTagToken();
|
1627
|
+
break;
|
1628
|
+
}
|
1629
|
+
case $.EOF: {
|
1630
|
+
this._err(ERR.eofInTag);
|
1631
|
+
this._emitEOFToken();
|
1632
|
+
break;
|
1633
|
+
}
|
1634
|
+
default: {
|
1635
|
+
this._createAttr('');
|
1636
|
+
this.state = State.ATTRIBUTE_NAME;
|
1637
|
+
this._stateAttributeName(cp);
|
1638
|
+
}
|
1639
|
+
}
|
1640
|
+
}
|
1641
|
+
// Before attribute value state
|
1642
|
+
//------------------------------------------------------------------
|
1643
|
+
_stateBeforeAttributeValue(cp) {
|
1644
|
+
switch (cp) {
|
1645
|
+
case $.SPACE:
|
1646
|
+
case $.LINE_FEED:
|
1647
|
+
case $.TABULATION:
|
1648
|
+
case $.FORM_FEED: {
|
1649
|
+
// Ignore whitespace
|
1650
|
+
break;
|
1651
|
+
}
|
1652
|
+
case $.QUOTATION_MARK: {
|
1653
|
+
this.state = State.ATTRIBUTE_VALUE_DOUBLE_QUOTED;
|
1654
|
+
break;
|
1655
|
+
}
|
1656
|
+
case $.APOSTROPHE: {
|
1657
|
+
this.state = State.ATTRIBUTE_VALUE_SINGLE_QUOTED;
|
1658
|
+
break;
|
1659
|
+
}
|
1660
|
+
case $.GREATER_THAN_SIGN: {
|
1661
|
+
this._err(ERR.missingAttributeValue);
|
1662
|
+
this.state = State.DATA;
|
1663
|
+
this.emitCurrentTagToken();
|
1664
|
+
break;
|
1665
|
+
}
|
1666
|
+
default: {
|
1667
|
+
this.state = State.ATTRIBUTE_VALUE_UNQUOTED;
|
1668
|
+
this._stateAttributeValueUnquoted(cp);
|
1669
|
+
}
|
1670
|
+
}
|
1671
|
+
}
|
1672
|
+
// Attribute value (double-quoted) state
|
1673
|
+
//------------------------------------------------------------------
|
1674
|
+
_stateAttributeValueDoubleQuoted(cp) {
|
1675
|
+
switch (cp) {
|
1676
|
+
case $.QUOTATION_MARK: {
|
1677
|
+
this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
|
1678
|
+
break;
|
1679
|
+
}
|
1680
|
+
case $.AMPERSAND: {
|
1681
|
+
this.returnState = State.ATTRIBUTE_VALUE_DOUBLE_QUOTED;
|
1682
|
+
this.state = State.CHARACTER_REFERENCE;
|
1683
|
+
break;
|
1684
|
+
}
|
1685
|
+
case $.NULL: {
|
1686
|
+
this._err(ERR.unexpectedNullCharacter);
|
1687
|
+
this.currentAttr.value += REPLACEMENT_CHARACTER;
|
1688
|
+
break;
|
1689
|
+
}
|
1690
|
+
case $.EOF: {
|
1691
|
+
this._err(ERR.eofInTag);
|
1692
|
+
this._emitEOFToken();
|
1693
|
+
break;
|
1694
|
+
}
|
1695
|
+
default: {
|
1696
|
+
this.currentAttr.value += String.fromCodePoint(cp);
|
1697
|
+
}
|
1698
|
+
}
|
1699
|
+
}
|
1700
|
+
// Attribute value (single-quoted) state
|
1701
|
+
//------------------------------------------------------------------
|
1702
|
+
_stateAttributeValueSingleQuoted(cp) {
|
1703
|
+
switch (cp) {
|
1704
|
+
case $.APOSTROPHE: {
|
1705
|
+
this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
|
1706
|
+
break;
|
1707
|
+
}
|
1708
|
+
case $.AMPERSAND: {
|
1709
|
+
this.returnState = State.ATTRIBUTE_VALUE_SINGLE_QUOTED;
|
1710
|
+
this.state = State.CHARACTER_REFERENCE;
|
1711
|
+
break;
|
1712
|
+
}
|
1713
|
+
case $.NULL: {
|
1714
|
+
this._err(ERR.unexpectedNullCharacter);
|
1715
|
+
this.currentAttr.value += REPLACEMENT_CHARACTER;
|
1716
|
+
break;
|
1717
|
+
}
|
1718
|
+
case $.EOF: {
|
1719
|
+
this._err(ERR.eofInTag);
|
1720
|
+
this._emitEOFToken();
|
1721
|
+
break;
|
1722
|
+
}
|
1723
|
+
default: {
|
1724
|
+
this.currentAttr.value += String.fromCodePoint(cp);
|
1725
|
+
}
|
1726
|
+
}
|
1727
|
+
}
|
1728
|
+
// Attribute value (unquoted) state
|
1729
|
+
//------------------------------------------------------------------
|
1730
|
+
_stateAttributeValueUnquoted(cp) {
|
1731
|
+
switch (cp) {
|
1732
|
+
case $.SPACE:
|
1733
|
+
case $.LINE_FEED:
|
1734
|
+
case $.TABULATION:
|
1735
|
+
case $.FORM_FEED: {
|
1736
|
+
this._leaveAttrValue();
|
1737
|
+
this.state = State.BEFORE_ATTRIBUTE_NAME;
|
1738
|
+
break;
|
1739
|
+
}
|
1740
|
+
case $.AMPERSAND: {
|
1741
|
+
this.returnState = State.ATTRIBUTE_VALUE_UNQUOTED;
|
1742
|
+
this.state = State.CHARACTER_REFERENCE;
|
1743
|
+
break;
|
1744
|
+
}
|
1745
|
+
case $.GREATER_THAN_SIGN: {
|
1746
|
+
this._leaveAttrValue();
|
1747
|
+
this.state = State.DATA;
|
1748
|
+
this.emitCurrentTagToken();
|
1749
|
+
break;
|
1750
|
+
}
|
1751
|
+
case $.NULL: {
|
1752
|
+
this._err(ERR.unexpectedNullCharacter);
|
1753
|
+
this.currentAttr.value += REPLACEMENT_CHARACTER;
|
1754
|
+
break;
|
1755
|
+
}
|
1756
|
+
case $.QUOTATION_MARK:
|
1757
|
+
case $.APOSTROPHE:
|
1758
|
+
case $.LESS_THAN_SIGN:
|
1759
|
+
case $.EQUALS_SIGN:
|
1760
|
+
case $.GRAVE_ACCENT: {
|
1761
|
+
this._err(ERR.unexpectedCharacterInUnquotedAttributeValue);
|
1762
|
+
this.currentAttr.value += String.fromCodePoint(cp);
|
1763
|
+
break;
|
1764
|
+
}
|
1765
|
+
case $.EOF: {
|
1766
|
+
this._err(ERR.eofInTag);
|
1767
|
+
this._emitEOFToken();
|
1768
|
+
break;
|
1769
|
+
}
|
1770
|
+
default: {
|
1771
|
+
this.currentAttr.value += String.fromCodePoint(cp);
|
1772
|
+
}
|
1773
|
+
}
|
1774
|
+
}
|
1775
|
+
// After attribute value (quoted) state
|
1776
|
+
//------------------------------------------------------------------
|
1777
|
+
_stateAfterAttributeValueQuoted(cp) {
|
1778
|
+
switch (cp) {
|
1779
|
+
case $.SPACE:
|
1780
|
+
case $.LINE_FEED:
|
1781
|
+
case $.TABULATION:
|
1782
|
+
case $.FORM_FEED: {
|
1783
|
+
this._leaveAttrValue();
|
1784
|
+
this.state = State.BEFORE_ATTRIBUTE_NAME;
|
1785
|
+
break;
|
1786
|
+
}
|
1787
|
+
case $.SOLIDUS: {
|
1788
|
+
this._leaveAttrValue();
|
1789
|
+
this.state = State.SELF_CLOSING_START_TAG;
|
1790
|
+
break;
|
1791
|
+
}
|
1792
|
+
case $.GREATER_THAN_SIGN: {
|
1793
|
+
this._leaveAttrValue();
|
1794
|
+
this.state = State.DATA;
|
1795
|
+
this.emitCurrentTagToken();
|
1796
|
+
break;
|
1797
|
+
}
|
1798
|
+
case $.EOF: {
|
1799
|
+
this._err(ERR.eofInTag);
|
1800
|
+
this._emitEOFToken();
|
1801
|
+
break;
|
1802
|
+
}
|
1803
|
+
default: {
|
1804
|
+
this._err(ERR.missingWhitespaceBetweenAttributes);
|
1805
|
+
this.state = State.BEFORE_ATTRIBUTE_NAME;
|
1806
|
+
this._stateBeforeAttributeName(cp);
|
1807
|
+
}
|
1808
|
+
}
|
1809
|
+
}
|
1810
|
+
// Self-closing start tag state
|
1811
|
+
//------------------------------------------------------------------
|
1812
|
+
_stateSelfClosingStartTag(cp) {
|
1813
|
+
switch (cp) {
|
1814
|
+
case $.GREATER_THAN_SIGN: {
|
1815
|
+
const token = this.currentToken;
|
1816
|
+
token.selfClosing = true;
|
1817
|
+
this.state = State.DATA;
|
1818
|
+
this.emitCurrentTagToken();
|
1819
|
+
break;
|
1820
|
+
}
|
1821
|
+
case $.EOF: {
|
1822
|
+
this._err(ERR.eofInTag);
|
1823
|
+
this._emitEOFToken();
|
1824
|
+
break;
|
1825
|
+
}
|
1826
|
+
default: {
|
1827
|
+
this._err(ERR.unexpectedSolidusInTag);
|
1828
|
+
this.state = State.BEFORE_ATTRIBUTE_NAME;
|
1829
|
+
this._stateBeforeAttributeName(cp);
|
1830
|
+
}
|
1831
|
+
}
|
1832
|
+
}
|
1833
|
+
// Bogus comment state
|
1834
|
+
//------------------------------------------------------------------
|
1835
|
+
_stateBogusComment(cp) {
|
1836
|
+
const token = this.currentToken;
|
1837
|
+
switch (cp) {
|
1838
|
+
case $.GREATER_THAN_SIGN: {
|
1839
|
+
this.state = State.DATA;
|
1840
|
+
this.emitCurrentComment(token);
|
1841
|
+
break;
|
1842
|
+
}
|
1843
|
+
case $.EOF: {
|
1844
|
+
this.emitCurrentComment(token);
|
1845
|
+
this._emitEOFToken();
|
1846
|
+
break;
|
1847
|
+
}
|
1848
|
+
case $.NULL: {
|
1849
|
+
this._err(ERR.unexpectedNullCharacter);
|
1850
|
+
token.data += REPLACEMENT_CHARACTER;
|
1851
|
+
break;
|
1852
|
+
}
|
1853
|
+
default: {
|
1854
|
+
token.data += String.fromCodePoint(cp);
|
1855
|
+
}
|
1856
|
+
}
|
1857
|
+
}
|
1858
|
+
// Markup declaration open state
|
1859
|
+
//------------------------------------------------------------------
|
1860
|
+
_stateMarkupDeclarationOpen(cp) {
|
1861
|
+
if (this._consumeSequenceIfMatch($$.DASH_DASH, true)) {
|
1862
|
+
this._createCommentToken($$.DASH_DASH.length + 1);
|
1863
|
+
this.state = State.COMMENT_START;
|
1864
|
+
}
|
1865
|
+
else if (this._consumeSequenceIfMatch($$.DOCTYPE, false)) {
|
1866
|
+
// NOTE: Doctypes tokens are created without fixed offsets. We keep track of the moment a doctype *might* start here.
|
1867
|
+
this.currentLocation = this.getCurrentLocation($$.DOCTYPE.length + 1);
|
1868
|
+
this.state = State.DOCTYPE;
|
1869
|
+
}
|
1870
|
+
else if (this._consumeSequenceIfMatch($$.CDATA_START, true)) {
|
1871
|
+
if (this.inForeignNode) {
|
1872
|
+
this.state = State.CDATA_SECTION;
|
1873
|
+
}
|
1874
|
+
else {
|
1875
|
+
this._err(ERR.cdataInHtmlContent);
|
1876
|
+
this._createCommentToken($$.CDATA_START.length + 1);
|
1877
|
+
this.currentToken.data = '[CDATA[';
|
1878
|
+
this.state = State.BOGUS_COMMENT;
|
1879
|
+
}
|
1880
|
+
}
|
1881
|
+
//NOTE: Sequence lookups can be abrupted by hibernation. In that case, lookup
|
1882
|
+
//results are no longer valid and we will need to start over.
|
1883
|
+
else if (!this._ensureHibernation()) {
|
1884
|
+
this._err(ERR.incorrectlyOpenedComment);
|
1885
|
+
this._createCommentToken(2);
|
1886
|
+
this.state = State.BOGUS_COMMENT;
|
1887
|
+
this._stateBogusComment(cp);
|
1888
|
+
}
|
1889
|
+
}
|
1890
|
+
// Comment start state
|
1891
|
+
//------------------------------------------------------------------
|
1892
|
+
_stateCommentStart(cp) {
|
1893
|
+
switch (cp) {
|
1894
|
+
case $.HYPHEN_MINUS: {
|
1895
|
+
this.state = State.COMMENT_START_DASH;
|
1896
|
+
break;
|
1897
|
+
}
|
1898
|
+
case $.GREATER_THAN_SIGN: {
|
1899
|
+
this._err(ERR.abruptClosingOfEmptyComment);
|
1900
|
+
this.state = State.DATA;
|
1901
|
+
const token = this.currentToken;
|
1902
|
+
this.emitCurrentComment(token);
|
1903
|
+
break;
|
1904
|
+
}
|
1905
|
+
default: {
|
1906
|
+
this.state = State.COMMENT;
|
1907
|
+
this._stateComment(cp);
|
1908
|
+
}
|
1909
|
+
}
|
1910
|
+
}
|
1911
|
+
// Comment start dash state
|
1912
|
+
//------------------------------------------------------------------
|
1913
|
+
_stateCommentStartDash(cp) {
|
1914
|
+
const token = this.currentToken;
|
1915
|
+
switch (cp) {
|
1916
|
+
case $.HYPHEN_MINUS: {
|
1917
|
+
this.state = State.COMMENT_END;
|
1918
|
+
break;
|
1919
|
+
}
|
1920
|
+
case $.GREATER_THAN_SIGN: {
|
1921
|
+
this._err(ERR.abruptClosingOfEmptyComment);
|
1922
|
+
this.state = State.DATA;
|
1923
|
+
this.emitCurrentComment(token);
|
1924
|
+
break;
|
1925
|
+
}
|
1926
|
+
case $.EOF: {
|
1927
|
+
this._err(ERR.eofInComment);
|
1928
|
+
this.emitCurrentComment(token);
|
1929
|
+
this._emitEOFToken();
|
1930
|
+
break;
|
1931
|
+
}
|
1932
|
+
default: {
|
1933
|
+
token.data += '-';
|
1934
|
+
this.state = State.COMMENT;
|
1935
|
+
this._stateComment(cp);
|
1936
|
+
}
|
1937
|
+
}
|
1938
|
+
}
|
1939
|
+
// Comment state
|
1940
|
+
//------------------------------------------------------------------
|
1941
|
+
_stateComment(cp) {
|
1942
|
+
const token = this.currentToken;
|
1943
|
+
switch (cp) {
|
1944
|
+
case $.HYPHEN_MINUS: {
|
1945
|
+
this.state = State.COMMENT_END_DASH;
|
1946
|
+
break;
|
1947
|
+
}
|
1948
|
+
case $.LESS_THAN_SIGN: {
|
1949
|
+
token.data += '<';
|
1950
|
+
this.state = State.COMMENT_LESS_THAN_SIGN;
|
1951
|
+
break;
|
1952
|
+
}
|
1953
|
+
case $.NULL: {
|
1954
|
+
this._err(ERR.unexpectedNullCharacter);
|
1955
|
+
token.data += REPLACEMENT_CHARACTER;
|
1956
|
+
break;
|
1957
|
+
}
|
1958
|
+
case $.EOF: {
|
1959
|
+
this._err(ERR.eofInComment);
|
1960
|
+
this.emitCurrentComment(token);
|
1961
|
+
this._emitEOFToken();
|
1962
|
+
break;
|
1963
|
+
}
|
1964
|
+
default: {
|
1965
|
+
token.data += String.fromCodePoint(cp);
|
1966
|
+
}
|
1967
|
+
}
|
1968
|
+
}
|
1969
|
+
// Comment less-than sign state
|
1970
|
+
//------------------------------------------------------------------
|
1971
|
+
_stateCommentLessThanSign(cp) {
|
1972
|
+
const token = this.currentToken;
|
1973
|
+
switch (cp) {
|
1974
|
+
case $.EXCLAMATION_MARK: {
|
1975
|
+
token.data += '!';
|
1976
|
+
this.state = State.COMMENT_LESS_THAN_SIGN_BANG;
|
1977
|
+
break;
|
1978
|
+
}
|
1979
|
+
case $.LESS_THAN_SIGN: {
|
1980
|
+
token.data += '<';
|
1981
|
+
break;
|
1982
|
+
}
|
1983
|
+
default: {
|
1984
|
+
this.state = State.COMMENT;
|
1985
|
+
this._stateComment(cp);
|
1986
|
+
}
|
1987
|
+
}
|
1988
|
+
}
|
1989
|
+
// Comment less-than sign bang state
|
1990
|
+
//------------------------------------------------------------------
|
1991
|
+
_stateCommentLessThanSignBang(cp) {
|
1992
|
+
if (cp === $.HYPHEN_MINUS) {
|
1993
|
+
this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH;
|
1994
|
+
}
|
1995
|
+
else {
|
1996
|
+
this.state = State.COMMENT;
|
1997
|
+
this._stateComment(cp);
|
1998
|
+
}
|
1999
|
+
}
|
2000
|
+
// Comment less-than sign bang dash state
|
2001
|
+
//------------------------------------------------------------------
|
2002
|
+
_stateCommentLessThanSignBangDash(cp) {
|
2003
|
+
if (cp === $.HYPHEN_MINUS) {
|
2004
|
+
this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH;
|
2005
|
+
}
|
2006
|
+
else {
|
2007
|
+
this.state = State.COMMENT_END_DASH;
|
2008
|
+
this._stateCommentEndDash(cp);
|
2009
|
+
}
|
2010
|
+
}
|
2011
|
+
// Comment less-than sign bang dash dash state
|
2012
|
+
//------------------------------------------------------------------
|
2013
|
+
_stateCommentLessThanSignBangDashDash(cp) {
|
2014
|
+
if (cp !== $.GREATER_THAN_SIGN && cp !== $.EOF) {
|
2015
|
+
this._err(ERR.nestedComment);
|
2016
|
+
}
|
2017
|
+
this.state = State.COMMENT_END;
|
2018
|
+
this._stateCommentEnd(cp);
|
2019
|
+
}
|
2020
|
+
// Comment end dash state
|
2021
|
+
//------------------------------------------------------------------
|
2022
|
+
_stateCommentEndDash(cp) {
|
2023
|
+
const token = this.currentToken;
|
2024
|
+
switch (cp) {
|
2025
|
+
case $.HYPHEN_MINUS: {
|
2026
|
+
this.state = State.COMMENT_END;
|
2027
|
+
break;
|
2028
|
+
}
|
2029
|
+
case $.EOF: {
|
2030
|
+
this._err(ERR.eofInComment);
|
2031
|
+
this.emitCurrentComment(token);
|
2032
|
+
this._emitEOFToken();
|
2033
|
+
break;
|
2034
|
+
}
|
2035
|
+
default: {
|
2036
|
+
token.data += '-';
|
2037
|
+
this.state = State.COMMENT;
|
2038
|
+
this._stateComment(cp);
|
2039
|
+
}
|
2040
|
+
}
|
2041
|
+
}
|
2042
|
+
// Comment end state
|
2043
|
+
//------------------------------------------------------------------
|
2044
|
+
_stateCommentEnd(cp) {
|
2045
|
+
const token = this.currentToken;
|
2046
|
+
switch (cp) {
|
2047
|
+
case $.GREATER_THAN_SIGN: {
|
2048
|
+
this.state = State.DATA;
|
2049
|
+
this.emitCurrentComment(token);
|
2050
|
+
break;
|
2051
|
+
}
|
2052
|
+
case $.EXCLAMATION_MARK: {
|
2053
|
+
this.state = State.COMMENT_END_BANG;
|
2054
|
+
break;
|
2055
|
+
}
|
2056
|
+
case $.HYPHEN_MINUS: {
|
2057
|
+
token.data += '-';
|
2058
|
+
break;
|
2059
|
+
}
|
2060
|
+
case $.EOF: {
|
2061
|
+
this._err(ERR.eofInComment);
|
2062
|
+
this.emitCurrentComment(token);
|
2063
|
+
this._emitEOFToken();
|
2064
|
+
break;
|
2065
|
+
}
|
2066
|
+
default: {
|
2067
|
+
token.data += '--';
|
2068
|
+
this.state = State.COMMENT;
|
2069
|
+
this._stateComment(cp);
|
2070
|
+
}
|
2071
|
+
}
|
2072
|
+
}
|
2073
|
+
// Comment end bang state
|
2074
|
+
//------------------------------------------------------------------
|
2075
|
+
_stateCommentEndBang(cp) {
|
2076
|
+
const token = this.currentToken;
|
2077
|
+
switch (cp) {
|
2078
|
+
case $.HYPHEN_MINUS: {
|
2079
|
+
token.data += '--!';
|
2080
|
+
this.state = State.COMMENT_END_DASH;
|
2081
|
+
break;
|
2082
|
+
}
|
2083
|
+
case $.GREATER_THAN_SIGN: {
|
2084
|
+
this._err(ERR.incorrectlyClosedComment);
|
2085
|
+
this.state = State.DATA;
|
2086
|
+
this.emitCurrentComment(token);
|
2087
|
+
break;
|
2088
|
+
}
|
2089
|
+
case $.EOF: {
|
2090
|
+
this._err(ERR.eofInComment);
|
2091
|
+
this.emitCurrentComment(token);
|
2092
|
+
this._emitEOFToken();
|
2093
|
+
break;
|
2094
|
+
}
|
2095
|
+
default: {
|
2096
|
+
token.data += '--!';
|
2097
|
+
this.state = State.COMMENT;
|
2098
|
+
this._stateComment(cp);
|
2099
|
+
}
|
2100
|
+
}
|
2101
|
+
}
|
2102
|
+
// DOCTYPE state
|
2103
|
+
//------------------------------------------------------------------
|
2104
|
+
_stateDoctype(cp) {
|
2105
|
+
switch (cp) {
|
2106
|
+
case $.SPACE:
|
2107
|
+
case $.LINE_FEED:
|
2108
|
+
case $.TABULATION:
|
2109
|
+
case $.FORM_FEED: {
|
2110
|
+
this.state = State.BEFORE_DOCTYPE_NAME;
|
2111
|
+
break;
|
2112
|
+
}
|
2113
|
+
case $.GREATER_THAN_SIGN: {
|
2114
|
+
this.state = State.BEFORE_DOCTYPE_NAME;
|
2115
|
+
this._stateBeforeDoctypeName(cp);
|
2116
|
+
break;
|
2117
|
+
}
|
2118
|
+
case $.EOF: {
|
2119
|
+
this._err(ERR.eofInDoctype);
|
2120
|
+
this._createDoctypeToken(null);
|
2121
|
+
const token = this.currentToken;
|
2122
|
+
token.forceQuirks = true;
|
2123
|
+
this.emitCurrentDoctype(token);
|
2124
|
+
this._emitEOFToken();
|
2125
|
+
break;
|
2126
|
+
}
|
2127
|
+
default: {
|
2128
|
+
this._err(ERR.missingWhitespaceBeforeDoctypeName);
|
2129
|
+
this.state = State.BEFORE_DOCTYPE_NAME;
|
2130
|
+
this._stateBeforeDoctypeName(cp);
|
2131
|
+
}
|
2132
|
+
}
|
2133
|
+
}
|
2134
|
+
// Before DOCTYPE name state
|
2135
|
+
//------------------------------------------------------------------
|
2136
|
+
_stateBeforeDoctypeName(cp) {
|
2137
|
+
if (isAsciiUpper(cp)) {
|
2138
|
+
this._createDoctypeToken(String.fromCharCode(toAsciiLower(cp)));
|
2139
|
+
this.state = State.DOCTYPE_NAME;
|
2140
|
+
}
|
2141
|
+
else
|
2142
|
+
switch (cp) {
|
2143
|
+
case $.SPACE:
|
2144
|
+
case $.LINE_FEED:
|
2145
|
+
case $.TABULATION:
|
2146
|
+
case $.FORM_FEED: {
|
2147
|
+
// Ignore whitespace
|
2148
|
+
break;
|
2149
|
+
}
|
2150
|
+
case $.NULL: {
|
2151
|
+
this._err(ERR.unexpectedNullCharacter);
|
2152
|
+
this._createDoctypeToken(REPLACEMENT_CHARACTER);
|
2153
|
+
this.state = State.DOCTYPE_NAME;
|
2154
|
+
break;
|
2155
|
+
}
|
2156
|
+
case $.GREATER_THAN_SIGN: {
|
2157
|
+
this._err(ERR.missingDoctypeName);
|
2158
|
+
this._createDoctypeToken(null);
|
2159
|
+
const token = this.currentToken;
|
2160
|
+
token.forceQuirks = true;
|
2161
|
+
this.emitCurrentDoctype(token);
|
2162
|
+
this.state = State.DATA;
|
2163
|
+
break;
|
2164
|
+
}
|
2165
|
+
case $.EOF: {
|
2166
|
+
this._err(ERR.eofInDoctype);
|
2167
|
+
this._createDoctypeToken(null);
|
2168
|
+
const token = this.currentToken;
|
2169
|
+
token.forceQuirks = true;
|
2170
|
+
this.emitCurrentDoctype(token);
|
2171
|
+
this._emitEOFToken();
|
2172
|
+
break;
|
2173
|
+
}
|
2174
|
+
default: {
|
2175
|
+
this._createDoctypeToken(String.fromCodePoint(cp));
|
2176
|
+
this.state = State.DOCTYPE_NAME;
|
2177
|
+
}
|
2178
|
+
}
|
2179
|
+
}
|
2180
|
+
// DOCTYPE name state
|
2181
|
+
//------------------------------------------------------------------
|
2182
|
+
_stateDoctypeName(cp) {
|
2183
|
+
const token = this.currentToken;
|
2184
|
+
switch (cp) {
|
2185
|
+
case $.SPACE:
|
2186
|
+
case $.LINE_FEED:
|
2187
|
+
case $.TABULATION:
|
2188
|
+
case $.FORM_FEED: {
|
2189
|
+
this.state = State.AFTER_DOCTYPE_NAME;
|
2190
|
+
break;
|
2191
|
+
}
|
2192
|
+
case $.GREATER_THAN_SIGN: {
|
2193
|
+
this.state = State.DATA;
|
2194
|
+
this.emitCurrentDoctype(token);
|
2195
|
+
break;
|
2196
|
+
}
|
2197
|
+
case $.NULL: {
|
2198
|
+
this._err(ERR.unexpectedNullCharacter);
|
2199
|
+
token.name += REPLACEMENT_CHARACTER;
|
2200
|
+
break;
|
2201
|
+
}
|
2202
|
+
case $.EOF: {
|
2203
|
+
this._err(ERR.eofInDoctype);
|
2204
|
+
token.forceQuirks = true;
|
2205
|
+
this.emitCurrentDoctype(token);
|
2206
|
+
this._emitEOFToken();
|
2207
|
+
break;
|
2208
|
+
}
|
2209
|
+
default: {
|
2210
|
+
token.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
|
2211
|
+
}
|
2212
|
+
}
|
2213
|
+
}
|
2214
|
+
// After DOCTYPE name state
|
2215
|
+
//------------------------------------------------------------------
|
2216
|
+
_stateAfterDoctypeName(cp) {
|
2217
|
+
const token = this.currentToken;
|
2218
|
+
switch (cp) {
|
2219
|
+
case $.SPACE:
|
2220
|
+
case $.LINE_FEED:
|
2221
|
+
case $.TABULATION:
|
2222
|
+
case $.FORM_FEED: {
|
2223
|
+
// Ignore whitespace
|
2224
|
+
break;
|
2225
|
+
}
|
2226
|
+
case $.GREATER_THAN_SIGN: {
|
2227
|
+
this.state = State.DATA;
|
2228
|
+
this.emitCurrentDoctype(token);
|
2229
|
+
break;
|
2230
|
+
}
|
2231
|
+
case $.EOF: {
|
2232
|
+
this._err(ERR.eofInDoctype);
|
2233
|
+
token.forceQuirks = true;
|
2234
|
+
this.emitCurrentDoctype(token);
|
2235
|
+
this._emitEOFToken();
|
2236
|
+
break;
|
2237
|
+
}
|
2238
|
+
default: {
|
2239
|
+
if (this._consumeSequenceIfMatch($$.PUBLIC, false)) {
|
2240
|
+
this.state = State.AFTER_DOCTYPE_PUBLIC_KEYWORD;
|
2241
|
+
}
|
2242
|
+
else if (this._consumeSequenceIfMatch($$.SYSTEM, false)) {
|
2243
|
+
this.state = State.AFTER_DOCTYPE_SYSTEM_KEYWORD;
|
2244
|
+
}
|
2245
|
+
//NOTE: sequence lookup can be abrupted by hibernation. In that case lookup
|
2246
|
+
//results are no longer valid and we will need to start over.
|
2247
|
+
else if (!this._ensureHibernation()) {
|
2248
|
+
this._err(ERR.invalidCharacterSequenceAfterDoctypeName);
|
2249
|
+
token.forceQuirks = true;
|
2250
|
+
this.state = State.BOGUS_DOCTYPE;
|
2251
|
+
this._stateBogusDoctype(cp);
|
2252
|
+
}
|
2253
|
+
}
|
2254
|
+
}
|
2255
|
+
}
|
2256
|
+
// After DOCTYPE public keyword state
|
2257
|
+
//------------------------------------------------------------------
|
2258
|
+
_stateAfterDoctypePublicKeyword(cp) {
|
2259
|
+
const token = this.currentToken;
|
2260
|
+
switch (cp) {
|
2261
|
+
case $.SPACE:
|
2262
|
+
case $.LINE_FEED:
|
2263
|
+
case $.TABULATION:
|
2264
|
+
case $.FORM_FEED: {
|
2265
|
+
this.state = State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;
|
2266
|
+
break;
|
2267
|
+
}
|
2268
|
+
case $.QUOTATION_MARK: {
|
2269
|
+
this._err(ERR.missingWhitespaceAfterDoctypePublicKeyword);
|
2270
|
+
token.publicId = '';
|
2271
|
+
this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
|
2272
|
+
break;
|
2273
|
+
}
|
2274
|
+
case $.APOSTROPHE: {
|
2275
|
+
this._err(ERR.missingWhitespaceAfterDoctypePublicKeyword);
|
2276
|
+
token.publicId = '';
|
2277
|
+
this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
|
2278
|
+
break;
|
2279
|
+
}
|
2280
|
+
case $.GREATER_THAN_SIGN: {
|
2281
|
+
this._err(ERR.missingDoctypePublicIdentifier);
|
2282
|
+
token.forceQuirks = true;
|
2283
|
+
this.state = State.DATA;
|
2284
|
+
this.emitCurrentDoctype(token);
|
2285
|
+
break;
|
2286
|
+
}
|
2287
|
+
case $.EOF: {
|
2288
|
+
this._err(ERR.eofInDoctype);
|
2289
|
+
token.forceQuirks = true;
|
2290
|
+
this.emitCurrentDoctype(token);
|
2291
|
+
this._emitEOFToken();
|
2292
|
+
break;
|
2293
|
+
}
|
2294
|
+
default: {
|
2295
|
+
this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);
|
2296
|
+
token.forceQuirks = true;
|
2297
|
+
this.state = State.BOGUS_DOCTYPE;
|
2298
|
+
this._stateBogusDoctype(cp);
|
2299
|
+
}
|
2300
|
+
}
|
2301
|
+
}
|
2302
|
+
// Before DOCTYPE public identifier state
|
2303
|
+
//------------------------------------------------------------------
|
2304
|
+
_stateBeforeDoctypePublicIdentifier(cp) {
|
2305
|
+
const token = this.currentToken;
|
2306
|
+
switch (cp) {
|
2307
|
+
case $.SPACE:
|
2308
|
+
case $.LINE_FEED:
|
2309
|
+
case $.TABULATION:
|
2310
|
+
case $.FORM_FEED: {
|
2311
|
+
// Ignore whitespace
|
2312
|
+
break;
|
2313
|
+
}
|
2314
|
+
case $.QUOTATION_MARK: {
|
2315
|
+
token.publicId = '';
|
2316
|
+
this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
|
2317
|
+
break;
|
2318
|
+
}
|
2319
|
+
case $.APOSTROPHE: {
|
2320
|
+
token.publicId = '';
|
2321
|
+
this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
|
2322
|
+
break;
|
2323
|
+
}
|
2324
|
+
case $.GREATER_THAN_SIGN: {
|
2325
|
+
this._err(ERR.missingDoctypePublicIdentifier);
|
2326
|
+
token.forceQuirks = true;
|
2327
|
+
this.state = State.DATA;
|
2328
|
+
this.emitCurrentDoctype(token);
|
2329
|
+
break;
|
2330
|
+
}
|
2331
|
+
case $.EOF: {
|
2332
|
+
this._err(ERR.eofInDoctype);
|
2333
|
+
token.forceQuirks = true;
|
2334
|
+
this.emitCurrentDoctype(token);
|
2335
|
+
this._emitEOFToken();
|
2336
|
+
break;
|
2337
|
+
}
|
2338
|
+
default: {
|
2339
|
+
this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);
|
2340
|
+
token.forceQuirks = true;
|
2341
|
+
this.state = State.BOGUS_DOCTYPE;
|
2342
|
+
this._stateBogusDoctype(cp);
|
2343
|
+
}
|
2344
|
+
}
|
2345
|
+
}
|
2346
|
+
// DOCTYPE public identifier (double-quoted) state
|
2347
|
+
//------------------------------------------------------------------
|
2348
|
+
_stateDoctypePublicIdentifierDoubleQuoted(cp) {
|
2349
|
+
const token = this.currentToken;
|
2350
|
+
switch (cp) {
|
2351
|
+
case $.QUOTATION_MARK: {
|
2352
|
+
this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
|
2353
|
+
break;
|
2354
|
+
}
|
2355
|
+
case $.NULL: {
|
2356
|
+
this._err(ERR.unexpectedNullCharacter);
|
2357
|
+
token.publicId += REPLACEMENT_CHARACTER;
|
2358
|
+
break;
|
2359
|
+
}
|
2360
|
+
case $.GREATER_THAN_SIGN: {
|
2361
|
+
this._err(ERR.abruptDoctypePublicIdentifier);
|
2362
|
+
token.forceQuirks = true;
|
2363
|
+
this.emitCurrentDoctype(token);
|
2364
|
+
this.state = State.DATA;
|
2365
|
+
break;
|
2366
|
+
}
|
2367
|
+
case $.EOF: {
|
2368
|
+
this._err(ERR.eofInDoctype);
|
2369
|
+
token.forceQuirks = true;
|
2370
|
+
this.emitCurrentDoctype(token);
|
2371
|
+
this._emitEOFToken();
|
2372
|
+
break;
|
2373
|
+
}
|
2374
|
+
default: {
|
2375
|
+
token.publicId += String.fromCodePoint(cp);
|
2376
|
+
}
|
2377
|
+
}
|
2378
|
+
}
|
2379
|
+
// DOCTYPE public identifier (single-quoted) state
|
2380
|
+
//------------------------------------------------------------------
|
2381
|
+
_stateDoctypePublicIdentifierSingleQuoted(cp) {
|
2382
|
+
const token = this.currentToken;
|
2383
|
+
switch (cp) {
|
2384
|
+
case $.APOSTROPHE: {
|
2385
|
+
this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
|
2386
|
+
break;
|
2387
|
+
}
|
2388
|
+
case $.NULL: {
|
2389
|
+
this._err(ERR.unexpectedNullCharacter);
|
2390
|
+
token.publicId += REPLACEMENT_CHARACTER;
|
2391
|
+
break;
|
2392
|
+
}
|
2393
|
+
case $.GREATER_THAN_SIGN: {
|
2394
|
+
this._err(ERR.abruptDoctypePublicIdentifier);
|
2395
|
+
token.forceQuirks = true;
|
2396
|
+
this.emitCurrentDoctype(token);
|
2397
|
+
this.state = State.DATA;
|
2398
|
+
break;
|
2399
|
+
}
|
2400
|
+
case $.EOF: {
|
2401
|
+
this._err(ERR.eofInDoctype);
|
2402
|
+
token.forceQuirks = true;
|
2403
|
+
this.emitCurrentDoctype(token);
|
2404
|
+
this._emitEOFToken();
|
2405
|
+
break;
|
2406
|
+
}
|
2407
|
+
default: {
|
2408
|
+
token.publicId += String.fromCodePoint(cp);
|
2409
|
+
}
|
2410
|
+
}
|
2411
|
+
}
|
2412
|
+
// After DOCTYPE public identifier state
|
2413
|
+
//------------------------------------------------------------------
|
2414
|
+
_stateAfterDoctypePublicIdentifier(cp) {
|
2415
|
+
const token = this.currentToken;
|
2416
|
+
switch (cp) {
|
2417
|
+
case $.SPACE:
|
2418
|
+
case $.LINE_FEED:
|
2419
|
+
case $.TABULATION:
|
2420
|
+
case $.FORM_FEED: {
|
2421
|
+
this.state = State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;
|
2422
|
+
break;
|
2423
|
+
}
|
2424
|
+
case $.GREATER_THAN_SIGN: {
|
2425
|
+
this.state = State.DATA;
|
2426
|
+
this.emitCurrentDoctype(token);
|
2427
|
+
break;
|
2428
|
+
}
|
2429
|
+
case $.QUOTATION_MARK: {
|
2430
|
+
this._err(ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);
|
2431
|
+
token.systemId = '';
|
2432
|
+
this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
|
2433
|
+
break;
|
2434
|
+
}
|
2435
|
+
case $.APOSTROPHE: {
|
2436
|
+
this._err(ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);
|
2437
|
+
token.systemId = '';
|
2438
|
+
this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
|
2439
|
+
break;
|
2440
|
+
}
|
2441
|
+
case $.EOF: {
|
2442
|
+
this._err(ERR.eofInDoctype);
|
2443
|
+
token.forceQuirks = true;
|
2444
|
+
this.emitCurrentDoctype(token);
|
2445
|
+
this._emitEOFToken();
|
2446
|
+
break;
|
2447
|
+
}
|
2448
|
+
default: {
|
2449
|
+
this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
|
2450
|
+
token.forceQuirks = true;
|
2451
|
+
this.state = State.BOGUS_DOCTYPE;
|
2452
|
+
this._stateBogusDoctype(cp);
|
2453
|
+
}
|
2454
|
+
}
|
2455
|
+
}
|
2456
|
+
// Between DOCTYPE public and system identifiers state
|
2457
|
+
//------------------------------------------------------------------
|
2458
|
+
_stateBetweenDoctypePublicAndSystemIdentifiers(cp) {
|
2459
|
+
const token = this.currentToken;
|
2460
|
+
switch (cp) {
|
2461
|
+
case $.SPACE:
|
2462
|
+
case $.LINE_FEED:
|
2463
|
+
case $.TABULATION:
|
2464
|
+
case $.FORM_FEED: {
|
2465
|
+
// Ignore whitespace
|
2466
|
+
break;
|
2467
|
+
}
|
2468
|
+
case $.GREATER_THAN_SIGN: {
|
2469
|
+
this.emitCurrentDoctype(token);
|
2470
|
+
this.state = State.DATA;
|
2471
|
+
break;
|
2472
|
+
}
|
2473
|
+
case $.QUOTATION_MARK: {
|
2474
|
+
token.systemId = '';
|
2475
|
+
this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
|
2476
|
+
break;
|
2477
|
+
}
|
2478
|
+
case $.APOSTROPHE: {
|
2479
|
+
token.systemId = '';
|
2480
|
+
this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
|
2481
|
+
break;
|
2482
|
+
}
|
2483
|
+
case $.EOF: {
|
2484
|
+
this._err(ERR.eofInDoctype);
|
2485
|
+
token.forceQuirks = true;
|
2486
|
+
this.emitCurrentDoctype(token);
|
2487
|
+
this._emitEOFToken();
|
2488
|
+
break;
|
2489
|
+
}
|
2490
|
+
default: {
|
2491
|
+
this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
|
2492
|
+
token.forceQuirks = true;
|
2493
|
+
this.state = State.BOGUS_DOCTYPE;
|
2494
|
+
this._stateBogusDoctype(cp);
|
2495
|
+
}
|
2496
|
+
}
|
2497
|
+
}
|
2498
|
+
// After DOCTYPE system keyword state
|
2499
|
+
//------------------------------------------------------------------
|
2500
|
+
_stateAfterDoctypeSystemKeyword(cp) {
|
2501
|
+
const token = this.currentToken;
|
2502
|
+
switch (cp) {
|
2503
|
+
case $.SPACE:
|
2504
|
+
case $.LINE_FEED:
|
2505
|
+
case $.TABULATION:
|
2506
|
+
case $.FORM_FEED: {
|
2507
|
+
this.state = State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;
|
2508
|
+
break;
|
2509
|
+
}
|
2510
|
+
case $.QUOTATION_MARK: {
|
2511
|
+
this._err(ERR.missingWhitespaceAfterDoctypeSystemKeyword);
|
2512
|
+
token.systemId = '';
|
2513
|
+
this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
|
2514
|
+
break;
|
2515
|
+
}
|
2516
|
+
case $.APOSTROPHE: {
|
2517
|
+
this._err(ERR.missingWhitespaceAfterDoctypeSystemKeyword);
|
2518
|
+
token.systemId = '';
|
2519
|
+
this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
|
2520
|
+
break;
|
2521
|
+
}
|
2522
|
+
case $.GREATER_THAN_SIGN: {
|
2523
|
+
this._err(ERR.missingDoctypeSystemIdentifier);
|
2524
|
+
token.forceQuirks = true;
|
2525
|
+
this.state = State.DATA;
|
2526
|
+
this.emitCurrentDoctype(token);
|
2527
|
+
break;
|
2528
|
+
}
|
2529
|
+
case $.EOF: {
|
2530
|
+
this._err(ERR.eofInDoctype);
|
2531
|
+
token.forceQuirks = true;
|
2532
|
+
this.emitCurrentDoctype(token);
|
2533
|
+
this._emitEOFToken();
|
2534
|
+
break;
|
2535
|
+
}
|
2536
|
+
default: {
|
2537
|
+
this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
|
2538
|
+
token.forceQuirks = true;
|
2539
|
+
this.state = State.BOGUS_DOCTYPE;
|
2540
|
+
this._stateBogusDoctype(cp);
|
2541
|
+
}
|
2542
|
+
}
|
2543
|
+
}
|
2544
|
+
// Before DOCTYPE system identifier state
|
2545
|
+
//------------------------------------------------------------------
|
2546
|
+
_stateBeforeDoctypeSystemIdentifier(cp) {
|
2547
|
+
const token = this.currentToken;
|
2548
|
+
switch (cp) {
|
2549
|
+
case $.SPACE:
|
2550
|
+
case $.LINE_FEED:
|
2551
|
+
case $.TABULATION:
|
2552
|
+
case $.FORM_FEED: {
|
2553
|
+
// Ignore whitespace
|
2554
|
+
break;
|
2555
|
+
}
|
2556
|
+
case $.QUOTATION_MARK: {
|
2557
|
+
token.systemId = '';
|
2558
|
+
this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
|
2559
|
+
break;
|
2560
|
+
}
|
2561
|
+
case $.APOSTROPHE: {
|
2562
|
+
token.systemId = '';
|
2563
|
+
this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
|
2564
|
+
break;
|
2565
|
+
}
|
2566
|
+
case $.GREATER_THAN_SIGN: {
|
2567
|
+
this._err(ERR.missingDoctypeSystemIdentifier);
|
2568
|
+
token.forceQuirks = true;
|
2569
|
+
this.state = State.DATA;
|
2570
|
+
this.emitCurrentDoctype(token);
|
2571
|
+
break;
|
2572
|
+
}
|
2573
|
+
case $.EOF: {
|
2574
|
+
this._err(ERR.eofInDoctype);
|
2575
|
+
token.forceQuirks = true;
|
2576
|
+
this.emitCurrentDoctype(token);
|
2577
|
+
this._emitEOFToken();
|
2578
|
+
break;
|
2579
|
+
}
|
2580
|
+
default: {
|
2581
|
+
this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
|
2582
|
+
token.forceQuirks = true;
|
2583
|
+
this.state = State.BOGUS_DOCTYPE;
|
2584
|
+
this._stateBogusDoctype(cp);
|
2585
|
+
}
|
2586
|
+
}
|
2587
|
+
}
|
2588
|
+
// DOCTYPE system identifier (double-quoted) state
|
2589
|
+
//------------------------------------------------------------------
|
2590
|
+
_stateDoctypeSystemIdentifierDoubleQuoted(cp) {
|
2591
|
+
const token = this.currentToken;
|
2592
|
+
switch (cp) {
|
2593
|
+
case $.QUOTATION_MARK: {
|
2594
|
+
this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
|
2595
|
+
break;
|
2596
|
+
}
|
2597
|
+
case $.NULL: {
|
2598
|
+
this._err(ERR.unexpectedNullCharacter);
|
2599
|
+
token.systemId += REPLACEMENT_CHARACTER;
|
2600
|
+
break;
|
2601
|
+
}
|
2602
|
+
case $.GREATER_THAN_SIGN: {
|
2603
|
+
this._err(ERR.abruptDoctypeSystemIdentifier);
|
2604
|
+
token.forceQuirks = true;
|
2605
|
+
this.emitCurrentDoctype(token);
|
2606
|
+
this.state = State.DATA;
|
2607
|
+
break;
|
2608
|
+
}
|
2609
|
+
case $.EOF: {
|
2610
|
+
this._err(ERR.eofInDoctype);
|
2611
|
+
token.forceQuirks = true;
|
2612
|
+
this.emitCurrentDoctype(token);
|
2613
|
+
this._emitEOFToken();
|
2614
|
+
break;
|
2615
|
+
}
|
2616
|
+
default: {
|
2617
|
+
token.systemId += String.fromCodePoint(cp);
|
2618
|
+
}
|
2619
|
+
}
|
2620
|
+
}
|
2621
|
+
// DOCTYPE system identifier (single-quoted) state
|
2622
|
+
//------------------------------------------------------------------
|
2623
|
+
_stateDoctypeSystemIdentifierSingleQuoted(cp) {
|
2624
|
+
const token = this.currentToken;
|
2625
|
+
switch (cp) {
|
2626
|
+
case $.APOSTROPHE: {
|
2627
|
+
this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
|
2628
|
+
break;
|
2629
|
+
}
|
2630
|
+
case $.NULL: {
|
2631
|
+
this._err(ERR.unexpectedNullCharacter);
|
2632
|
+
token.systemId += REPLACEMENT_CHARACTER;
|
2633
|
+
break;
|
2634
|
+
}
|
2635
|
+
case $.GREATER_THAN_SIGN: {
|
2636
|
+
this._err(ERR.abruptDoctypeSystemIdentifier);
|
2637
|
+
token.forceQuirks = true;
|
2638
|
+
this.emitCurrentDoctype(token);
|
2639
|
+
this.state = State.DATA;
|
2640
|
+
break;
|
2641
|
+
}
|
2642
|
+
case $.EOF: {
|
2643
|
+
this._err(ERR.eofInDoctype);
|
2644
|
+
token.forceQuirks = true;
|
2645
|
+
this.emitCurrentDoctype(token);
|
2646
|
+
this._emitEOFToken();
|
2647
|
+
break;
|
2648
|
+
}
|
2649
|
+
default: {
|
2650
|
+
token.systemId += String.fromCodePoint(cp);
|
2651
|
+
}
|
2652
|
+
}
|
2653
|
+
}
|
2654
|
+
// After DOCTYPE system identifier state
|
2655
|
+
//------------------------------------------------------------------
|
2656
|
+
_stateAfterDoctypeSystemIdentifier(cp) {
|
2657
|
+
const token = this.currentToken;
|
2658
|
+
switch (cp) {
|
2659
|
+
case $.SPACE:
|
2660
|
+
case $.LINE_FEED:
|
2661
|
+
case $.TABULATION:
|
2662
|
+
case $.FORM_FEED: {
|
2663
|
+
// Ignore whitespace
|
2664
|
+
break;
|
2665
|
+
}
|
2666
|
+
case $.GREATER_THAN_SIGN: {
|
2667
|
+
this.emitCurrentDoctype(token);
|
2668
|
+
this.state = State.DATA;
|
2669
|
+
break;
|
2670
|
+
}
|
2671
|
+
case $.EOF: {
|
2672
|
+
this._err(ERR.eofInDoctype);
|
2673
|
+
token.forceQuirks = true;
|
2674
|
+
this.emitCurrentDoctype(token);
|
2675
|
+
this._emitEOFToken();
|
2676
|
+
break;
|
2677
|
+
}
|
2678
|
+
default: {
|
2679
|
+
this._err(ERR.unexpectedCharacterAfterDoctypeSystemIdentifier);
|
2680
|
+
this.state = State.BOGUS_DOCTYPE;
|
2681
|
+
this._stateBogusDoctype(cp);
|
2682
|
+
}
|
2683
|
+
}
|
2684
|
+
}
|
2685
|
+
// Bogus DOCTYPE state
|
2686
|
+
//------------------------------------------------------------------
|
2687
|
+
_stateBogusDoctype(cp) {
|
2688
|
+
const token = this.currentToken;
|
2689
|
+
switch (cp) {
|
2690
|
+
case $.GREATER_THAN_SIGN: {
|
2691
|
+
this.emitCurrentDoctype(token);
|
2692
|
+
this.state = State.DATA;
|
2693
|
+
break;
|
2694
|
+
}
|
2695
|
+
case $.NULL: {
|
2696
|
+
this._err(ERR.unexpectedNullCharacter);
|
2697
|
+
break;
|
2698
|
+
}
|
2699
|
+
case $.EOF: {
|
2700
|
+
this.emitCurrentDoctype(token);
|
2701
|
+
this._emitEOFToken();
|
2702
|
+
break;
|
2703
|
+
}
|
2704
|
+
default:
|
2705
|
+
// Do nothing
|
2706
|
+
}
|
2707
|
+
}
|
2708
|
+
// CDATA section state
|
2709
|
+
//------------------------------------------------------------------
|
2710
|
+
_stateCdataSection(cp) {
|
2711
|
+
switch (cp) {
|
2712
|
+
case $.RIGHT_SQUARE_BRACKET: {
|
2713
|
+
this.state = State.CDATA_SECTION_BRACKET;
|
2714
|
+
break;
|
2715
|
+
}
|
2716
|
+
case $.EOF: {
|
2717
|
+
this._err(ERR.eofInCdata);
|
2718
|
+
this._emitEOFToken();
|
2719
|
+
break;
|
2720
|
+
}
|
2721
|
+
default: {
|
2722
|
+
this._emitCodePoint(cp);
|
2723
|
+
}
|
2724
|
+
}
|
2725
|
+
}
|
2726
|
+
// CDATA section bracket state
|
2727
|
+
//------------------------------------------------------------------
|
2728
|
+
_stateCdataSectionBracket(cp) {
|
2729
|
+
if (cp === $.RIGHT_SQUARE_BRACKET) {
|
2730
|
+
this.state = State.CDATA_SECTION_END;
|
2731
|
+
}
|
2732
|
+
else {
|
2733
|
+
this._emitChars(']');
|
2734
|
+
this.state = State.CDATA_SECTION;
|
2735
|
+
this._stateCdataSection(cp);
|
2736
|
+
}
|
2737
|
+
}
|
2738
|
+
// CDATA section end state
|
2739
|
+
//------------------------------------------------------------------
|
2740
|
+
_stateCdataSectionEnd(cp) {
|
2741
|
+
switch (cp) {
|
2742
|
+
case $.GREATER_THAN_SIGN: {
|
2743
|
+
this.state = State.DATA;
|
2744
|
+
break;
|
2745
|
+
}
|
2746
|
+
case $.RIGHT_SQUARE_BRACKET: {
|
2747
|
+
this._emitChars(']');
|
2748
|
+
break;
|
2749
|
+
}
|
2750
|
+
default: {
|
2751
|
+
this._emitChars(']]');
|
2752
|
+
this.state = State.CDATA_SECTION;
|
2753
|
+
this._stateCdataSection(cp);
|
2754
|
+
}
|
2755
|
+
}
|
2756
|
+
}
|
2757
|
+
// Character reference state
|
2758
|
+
//------------------------------------------------------------------
|
2759
|
+
_stateCharacterReference(cp) {
|
2760
|
+
if (cp === $.NUMBER_SIGN) {
|
2761
|
+
this.state = State.NUMERIC_CHARACTER_REFERENCE;
|
2762
|
+
}
|
2763
|
+
else if (isAsciiAlphaNumeric(cp)) {
|
2764
|
+
this.state = State.NAMED_CHARACTER_REFERENCE;
|
2765
|
+
this._stateNamedCharacterReference(cp);
|
2766
|
+
}
|
2767
|
+
else {
|
2768
|
+
this._flushCodePointConsumedAsCharacterReference($.AMPERSAND);
|
2769
|
+
this._reconsumeInState(this.returnState, cp);
|
2770
|
+
}
|
2771
|
+
}
|
2772
|
+
// Named character reference state
|
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;
|
2786
|
+
}
|
2787
|
+
else {
|
2788
|
+
this._flushCodePointConsumedAsCharacterReference($.AMPERSAND);
|
2789
|
+
this.state = State.AMBIGUOUS_AMPERSAND;
|
2790
|
+
}
|
2791
|
+
}
|
2792
|
+
// Ambiguos ampersand state
|
2793
|
+
//------------------------------------------------------------------
|
2794
|
+
_stateAmbiguousAmpersand(cp) {
|
2795
|
+
if (isAsciiAlphaNumeric(cp)) {
|
2796
|
+
this._flushCodePointConsumedAsCharacterReference(cp);
|
2797
|
+
}
|
2798
|
+
else {
|
2799
|
+
if (cp === $.SEMICOLON) {
|
2800
|
+
this._err(ERR.unknownNamedCharacterReference);
|
2801
|
+
}
|
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
|
+
this.state = this.returnState;
|
2837
|
+
}
|
2838
|
+
}
|
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
|
+
}
|
2904
|
+
//# sourceMappingURL=index.js.map
|