adspecs 0.1.41 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.adspecs/scripts/powershell/check-prerequisites.ps1 +3 -3
- package/.adspecs/scripts/powershell/setup-tasks.ps1 +2 -2
- package/.adspecs/templates/01-/344/270/232/345/212/241/351/234/200/346/261/202/345/210/206/346/236/220/346/250/241/346/235/277.md +3 -3
- package/.adspecs/templates/02-/344/272/247/345/223/201/351/234/200/346/261/202/350/257/264/346/230/216/344/271/246/346/250/241/346/235/277.md +1 -1
- package/.adspecs/templates/03-/347/263/273/347/273/237/350/256/276/350/256/241/346/250/241/346/235/277.md +1 -1
- package/.adspecs/templates/05-/345/220/216/347/253/257/344/273/273/345/212/241/346/270/205/345/215/225/346/250/241/346/235/277.md +613 -613
- package/.adspecs/templates/05b-/345/211/215/347/253/257/344/273/273/345/212/241/346/270/205/345/215/225/346/250/241/346/235/277.md +583 -583
- package/.adspecs/templates/14-/351/234/200/346/261/202/350/277/275/346/272/257/347/237/251/351/230/265/346/250/241/346/235/277.md +1 -1
- package/.claude-plugin/marketplace.json +23 -23
- package/.claude-plugin/plugin.json +18 -18
- package/.codebuddy-plugin/plugin.json +24 -24
- package/.qoder-plugin/plugin.json +30 -30
- package/.workbuddy-plugin/plugin.json +24 -24
- package/CHANGELOG.md +10 -0
- package/CLAUDE.md +45 -45
- package/README.md +51 -51
- package/hooks/commit-queue.js +245 -245
- package/hooks/hooks.json +2 -9
- package/hooks/session-logger.js +346 -346
- package/package.json +65 -65
- package/skills/{adspecs-adversarial-review → ads-adversarial-review}/SKILL.md +8 -8
- package/skills/{adspecs-analyze → ads-analyze}/SKILL.md +564 -564
- package/skills/{adspecs-architecture-planning → ads-architecture-planning}/SKILL.md +9 -9
- package/skills/{adspecs-biz-blueprint → ads-biz-blueprint}/SKILL.md +18 -18
- package/skills/{adspecs-clarify → ads-clarify}/SKILL.md +7 -7
- package/skills/{adspecs-constitution → ads-constitution}/SKILL.md +3 -3
- package/skills/{adspecs-export-word → ads-export-word}/SKILL.md +9 -9
- package/skills/{adspecs-export-word → ads-export-word}/references/md-to-docx.js +862 -862
- package/skills/ads-export-word/references/package-lock.json +220 -0
- package/skills/{adspecs-export-word → ads-export-word}/references/package.json +10 -10
- package/skills/{adspecs-front-prototype → ads-front-prototype}/SKILL.md +8 -8
- package/skills/{adspecs-front-spec → ads-front-spec}/SKILL.md +12 -12
- package/skills/{adspecs-front-tasks → ads-front-tasks}/SKILL.md +5 -5
- package/skills/{adspecs-git-commit → ads-git-commit}/SKILL.md +1 -1
- package/skills/{adspecs-git-initialize → ads-git-initialize}/SKILL.md +1 -1
- package/skills/{adspecs-new-requirement → ads-new-requirement}/SKILL.md +11 -11
- package/skills/{adspecs-plan → ads-plan}/SKILL.md +6 -6
- package/skills/{adspecs-prd → ads-prd}/SKILL.md +9 -9
- package/skills/{adspecs-prd-to-demo → ads-prd-to-demo}/SKILL.md +19 -19
- package/skills/{adspecs-requirement-research → ads-requirement-research}/SKILL.md +15 -3
- package/skills/{adspecs-save-session → ads-save-session}/SKILL.md +1 -1
- package/skills/{adspecs-tasks → ads-tasks}/SKILL.md +5 -5
- package/skills/{adspecs-update-status → ads-update-status}/SKILL.md +7 -7
- package/skills/{adspecs-utest → ads-utest}/SKILL.md +7 -7
- package/skills/{adspecs-write-planning-report → ads-write-planning-report}/SKILL.md +2 -2
- package/skills/{adspecs-write-roadmap → ads-write-roadmap}/SKILL.md +2 -2
- package/skills/{adspecs-write-sow → ads-write-sow}/SKILL.md +5 -5
- package/skills/adspecs-export-word/references/node_modules/.bin/marked +16 -0
- package/skills/adspecs-export-word/references/node_modules/.bin/marked.cmd +17 -0
- package/skills/adspecs-export-word/references/node_modules/.bin/marked.ps1 +28 -0
- package/skills/adspecs-export-word/references/node_modules/.bin/nanoid +16 -0
- package/skills/adspecs-export-word/references/node_modules/.bin/nanoid.cmd +17 -0
- package/skills/adspecs-export-word/references/node_modules/.bin/nanoid.ps1 +28 -0
- package/skills/adspecs-export-word/references/node_modules/.bin/xml-js +16 -0
- package/skills/adspecs-export-word/references/node_modules/.bin/xml-js.cmd +17 -0
- package/skills/adspecs-export-word/references/node_modules/.bin/xml-js.ps1 +28 -0
- package/skills/adspecs-export-word/references/{package-lock.json → node_modules/.package-lock.json} +0 -8
- package/skills/adspecs-export-word/references/node_modules/@types/node/LICENSE +21 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/README.md +15 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/assert/strict.d.ts +59 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/assert.d.ts +950 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/async_hooks.d.ts +711 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/buffer.buffer.d.ts +466 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/buffer.d.ts +1765 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/child_process.d.ts +1366 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/cluster.d.ts +432 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/console.d.ts +93 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/constants.d.ts +14 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/crypto.d.ts +4058 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/dgram.d.ts +537 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/diagnostics_channel.d.ts +552 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/dns/promises.d.ts +497 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/dns.d.ts +876 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/domain.d.ts +150 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/events.d.ts +1008 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/fs/promises.d.ts +1468 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/fs.d.ts +4780 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/globals.d.ts +150 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/globals.typedarray.d.ts +101 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/http.d.ts +2147 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/http2.d.ts +2489 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/https.d.ts +400 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/index.d.ts +117 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/inspector/promises.d.ts +35 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/inspector.d.ts +264 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/inspector.generated.d.ts +4406 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/module.d.ts +755 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/net.d.ts +970 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/os.d.ts +498 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/package.json +155 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/path/posix.d.ts +8 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/path/win32.d.ts +8 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/path.d.ts +178 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/perf_hooks.d.ts +612 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/process.d.ts +2206 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/punycode.d.ts +89 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/querystring.d.ts +139 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/quic.d.ts +897 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/readline/promises.d.ts +158 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/readline.d.ts +507 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/repl.d.ts +420 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/sea.d.ts +47 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/sqlite.d.ts +1068 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/stream/consumers.d.ts +114 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/stream/iter.d.ts +301 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/stream/promises.d.ts +211 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/stream/web.d.ts +300 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/stream.d.ts +1774 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/string_decoder.d.ts +27 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/test/reporters.d.ts +59 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/test.d.ts +2279 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/timers.d.ts +149 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/tls.d.ts +1193 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/trace_events.d.ts +103 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +462 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/ts5.6/index.d.ts +119 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/ts5.7/index.d.ts +119 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/tty.d.ts +225 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/url.d.ts +556 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/util/types.d.ts +558 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/util.d.ts +1677 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/v8.d.ts +980 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/vm.d.ts +1136 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/wasi.d.ts +131 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/blob.d.ts +23 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/console.d.ts +9 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/events.d.ts +106 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/performance.d.ts +45 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/streams.d.ts +115 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/timers.d.ts +44 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/web-globals/url.d.ts +24 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/worker_threads.d.ts +671 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/zlib/iter.d.ts +131 -0
- package/skills/adspecs-export-word/references/node_modules/@types/node/zlib.d.ts +589 -0
- package/skills/adspecs-export-word/references/node_modules/core-util-is/LICENSE +19 -0
- package/skills/adspecs-export-word/references/node_modules/core-util-is/README.md +3 -0
- package/skills/adspecs-export-word/references/node_modules/core-util-is/lib/util.js +107 -0
- package/skills/adspecs-export-word/references/node_modules/core-util-is/package.json +38 -0
- package/skills/adspecs-export-word/references/node_modules/docx/LICENSE +21 -0
- package/skills/adspecs-export-word/references/node_modules/docx/README.md +124 -0
- package/skills/adspecs-export-word/references/node_modules/docx/dist/index.cjs +33170 -0
- package/skills/adspecs-export-word/references/node_modules/docx/dist/index.d.cts +3214 -0
- package/skills/adspecs-export-word/references/node_modules/docx/dist/index.d.ts +3214 -0
- package/skills/adspecs-export-word/references/node_modules/docx/dist/index.iife.js +33173 -0
- package/skills/adspecs-export-word/references/node_modules/docx/dist/index.mjs +32868 -0
- package/skills/adspecs-export-word/references/node_modules/docx/dist/index.umd.cjs +33174 -0
- package/skills/adspecs-export-word/references/node_modules/docx/package.json +114 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/.eslintrc.js +41 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/.travis.yml +10 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/README.md +48 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash/common.js +92 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash/hmac.js +47 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash/ripemd.js +146 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash/sha/1.js +74 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash/sha/224.js +30 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash/sha/256.js +105 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash/sha/384.js +35 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash/sha/512.js +330 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash/sha/common.js +49 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash/sha.js +7 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash/utils.js +278 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash.d.ts +106 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/lib/hash.js +15 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/package.json +35 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/test/hash-test.js +140 -0
- package/skills/adspecs-export-word/references/node_modules/hash.js/test/hmac-test.js +62 -0
- package/skills/adspecs-export-word/references/node_modules/immediate/LICENSE.txt +20 -0
- package/skills/adspecs-export-word/references/node_modules/immediate/README.md +93 -0
- package/skills/adspecs-export-word/references/node_modules/immediate/dist/immediate.js +75 -0
- package/skills/adspecs-export-word/references/node_modules/immediate/dist/immediate.min.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/immediate/lib/browser.js +69 -0
- package/skills/adspecs-export-word/references/node_modules/immediate/lib/index.js +73 -0
- package/skills/adspecs-export-word/references/node_modules/immediate/package.json +42 -0
- package/skills/adspecs-export-word/references/node_modules/inherits/LICENSE +16 -0
- package/skills/adspecs-export-word/references/node_modules/inherits/README.md +42 -0
- package/skills/adspecs-export-word/references/node_modules/inherits/inherits.js +9 -0
- package/skills/adspecs-export-word/references/node_modules/inherits/inherits_browser.js +27 -0
- package/skills/adspecs-export-word/references/node_modules/inherits/package.json +29 -0
- package/skills/adspecs-export-word/references/node_modules/isarray/.travis.yml +4 -0
- package/skills/adspecs-export-word/references/node_modules/isarray/Makefile +6 -0
- package/skills/adspecs-export-word/references/node_modules/isarray/README.md +60 -0
- package/skills/adspecs-export-word/references/node_modules/isarray/component.json +19 -0
- package/skills/adspecs-export-word/references/node_modules/isarray/index.js +5 -0
- package/skills/adspecs-export-word/references/node_modules/isarray/package.json +45 -0
- package/skills/adspecs-export-word/references/node_modules/isarray/test.js +20 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/.codeclimate.yml +16 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/.editorconfig +8 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/.eslintrc.js +43 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/.github/workflows/pr.yaml +58 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/.jekyll-metadata +0 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/.travis.yml +17 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/CHANGES.md +204 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/LICENSE.markdown +651 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/README.markdown +33 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/deps.js +37 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/dist/jszip.js +11577 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/dist/jszip.min.js +13 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/graph.svg +601 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/index.d.ts +330 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/base64.js +106 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/compressedObject.js +74 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/compressions.js +14 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/crc32.js +77 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/defaults.js +11 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/external.js +18 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/flate.js +85 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/generate/ZipFileWorker.js +539 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/generate/index.js +57 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/index.js +55 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/license_header.js +11 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/load.js +88 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/nodejsUtils.js +57 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/object.js +384 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/readable-stream-browser.js +10 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/reader/DataReader.js +116 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/reader/StringReader.js +38 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/reader/readerFor.js +28 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/signature.js +7 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/stream/DataWorker.js +116 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/stream/StreamHelper.js +214 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/support.js +38 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/utf8.js +275 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/utils.js +501 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/zipEntries.js +261 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/zipEntry.js +293 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/lib/zipObject.js +133 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/package.json +67 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/sponsors.md +21 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/tsconfig.json +101 -0
- package/skills/adspecs-export-word/references/node_modules/jszip/vendor/FileSaver.js +247 -0
- package/skills/adspecs-export-word/references/node_modules/lie/README.md +62 -0
- package/skills/adspecs-export-word/references/node_modules/lie/dist/lie.js +350 -0
- package/skills/adspecs-export-word/references/node_modules/lie/dist/lie.min.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/lie/dist/lie.polyfill.js +358 -0
- package/skills/adspecs-export-word/references/node_modules/lie/dist/lie.polyfill.min.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/lie/lib/browser.js +273 -0
- package/skills/adspecs-export-word/references/node_modules/lie/lib/index.js +298 -0
- package/skills/adspecs-export-word/references/node_modules/lie/license.md +7 -0
- package/skills/adspecs-export-word/references/node_modules/lie/lie.d.ts +244 -0
- package/skills/adspecs-export-word/references/node_modules/lie/package.json +69 -0
- package/skills/adspecs-export-word/references/node_modules/lie/polyfill.js +4 -0
- package/skills/adspecs-export-word/references/node_modules/marked/LICENSE.md +44 -0
- package/skills/adspecs-export-word/references/node_modules/marked/README.md +106 -0
- package/skills/adspecs-export-word/references/node_modules/marked/bin/main.js +282 -0
- package/skills/adspecs-export-word/references/node_modules/marked/bin/marked.js +15 -0
- package/skills/adspecs-export-word/references/node_modules/marked/lib/marked.cjs +2211 -0
- package/skills/adspecs-export-word/references/node_modules/marked/lib/marked.cjs.map +7 -0
- package/skills/adspecs-export-word/references/node_modules/marked/lib/marked.d.cts +728 -0
- package/skills/adspecs-export-word/references/node_modules/marked/lib/marked.d.ts +728 -0
- package/skills/adspecs-export-word/references/node_modules/marked/lib/marked.esm.js +2189 -0
- package/skills/adspecs-export-word/references/node_modules/marked/lib/marked.esm.js.map +7 -0
- package/skills/adspecs-export-word/references/node_modules/marked/lib/marked.umd.js +2213 -0
- package/skills/adspecs-export-word/references/node_modules/marked/lib/marked.umd.js.map +7 -0
- package/skills/adspecs-export-word/references/node_modules/marked/man/marked.1 +111 -0
- package/skills/adspecs-export-word/references/node_modules/marked/man/marked.1.md +92 -0
- package/skills/adspecs-export-word/references/node_modules/marked/marked.min.js +69 -0
- package/skills/adspecs-export-word/references/node_modules/marked/package.json +111 -0
- package/skills/adspecs-export-word/references/node_modules/minimalistic-assert/LICENSE +13 -0
- package/skills/adspecs-export-word/references/node_modules/minimalistic-assert/index.js +11 -0
- package/skills/adspecs-export-word/references/node_modules/minimalistic-assert/package.json +19 -0
- package/skills/adspecs-export-word/references/node_modules/minimalistic-assert/readme.md +4 -0
- package/skills/adspecs-export-word/references/node_modules/nanoid/LICENSE +20 -0
- package/skills/adspecs-export-word/references/node_modules/nanoid/README.md +34 -0
- package/skills/adspecs-export-word/references/node_modules/nanoid/bin/nanoid.js +66 -0
- package/skills/adspecs-export-word/references/node_modules/nanoid/index.browser.js +57 -0
- package/skills/adspecs-export-word/references/node_modules/nanoid/index.d.ts +106 -0
- package/skills/adspecs-export-word/references/node_modules/nanoid/index.js +83 -0
- package/skills/adspecs-export-word/references/node_modules/nanoid/nanoid.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/nanoid/non-secure/index.d.ts +48 -0
- package/skills/adspecs-export-word/references/node_modules/nanoid/non-secure/index.js +23 -0
- package/skills/adspecs-export-word/references/node_modules/nanoid/package.json +46 -0
- package/skills/adspecs-export-word/references/node_modules/nanoid/url-alphabet/index.js +2 -0
- package/skills/adspecs-export-word/references/node_modules/pako/CHANGELOG.md +164 -0
- package/skills/adspecs-export-word/references/node_modules/pako/LICENSE +21 -0
- package/skills/adspecs-export-word/references/node_modules/pako/README.md +191 -0
- package/skills/adspecs-export-word/references/node_modules/pako/dist/pako.js +6818 -0
- package/skills/adspecs-export-word/references/node_modules/pako/dist/pako.min.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/pako/dist/pako_deflate.js +3997 -0
- package/skills/adspecs-export-word/references/node_modules/pako/dist/pako_deflate.min.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/pako/dist/pako_inflate.js +3300 -0
- package/skills/adspecs-export-word/references/node_modules/pako/dist/pako_inflate.min.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/pako/index.js +14 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/deflate.js +400 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/inflate.js +423 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/utils/common.js +105 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/utils/strings.js +187 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/README +59 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/adler32.js +51 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/constants.js +68 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/crc32.js +59 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/deflate.js +1874 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/gzheader.js +58 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/inffast.js +345 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/inflate.js +1556 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/inftrees.js +343 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/messages.js +32 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/trees.js +1222 -0
- package/skills/adspecs-export-word/references/node_modules/pako/lib/zlib/zstream.js +47 -0
- package/skills/adspecs-export-word/references/node_modules/pako/package.json +44 -0
- package/skills/adspecs-export-word/references/node_modules/process-nextick-args/index.js +45 -0
- package/skills/adspecs-export-word/references/node_modules/process-nextick-args/license.md +19 -0
- package/skills/adspecs-export-word/references/node_modules/process-nextick-args/package.json +25 -0
- package/skills/adspecs-export-word/references/node_modules/process-nextick-args/readme.md +18 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/.travis.yml +34 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/GOVERNANCE.md +136 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/LICENSE +47 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/README.md +58 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/duplex-browser.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/duplex.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/lib/_stream_transform.js +214 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/lib/_stream_writable.js +685 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/lib/internal/streams/BufferList.js +78 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/lib/internal/streams/destroy.js +84 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/package.json +52 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/passthrough.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/readable-browser.js +7 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/readable.js +19 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/transform.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/writable-browser.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/readable-stream/writable.js +8 -0
- package/skills/adspecs-export-word/references/node_modules/safe-buffer/LICENSE +21 -0
- package/skills/adspecs-export-word/references/node_modules/safe-buffer/README.md +584 -0
- package/skills/adspecs-export-word/references/node_modules/safe-buffer/index.d.ts +187 -0
- package/skills/adspecs-export-word/references/node_modules/safe-buffer/index.js +62 -0
- package/skills/adspecs-export-word/references/node_modules/safe-buffer/package.json +37 -0
- package/skills/adspecs-export-word/references/node_modules/sax/LICENSE.md +55 -0
- package/skills/adspecs-export-word/references/node_modules/sax/README.md +227 -0
- package/skills/adspecs-export-word/references/node_modules/sax/lib/sax.js +1848 -0
- package/skills/adspecs-export-word/references/node_modules/sax/package.json +34 -0
- package/skills/adspecs-export-word/references/node_modules/setimmediate/LICENSE.txt +20 -0
- package/skills/adspecs-export-word/references/node_modules/setimmediate/package.json +30 -0
- package/skills/adspecs-export-word/references/node_modules/setimmediate/setImmediate.js +186 -0
- package/skills/adspecs-export-word/references/node_modules/string_decoder/.travis.yml +50 -0
- package/skills/adspecs-export-word/references/node_modules/string_decoder/LICENSE +48 -0
- package/skills/adspecs-export-word/references/node_modules/string_decoder/README.md +47 -0
- package/skills/adspecs-export-word/references/node_modules/string_decoder/lib/string_decoder.js +296 -0
- package/skills/adspecs-export-word/references/node_modules/string_decoder/package.json +31 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/LICENSE +21 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/README.md +6 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/agent.d.ts +32 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/api.d.ts +43 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/balanced-pool.d.ts +30 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/cache-interceptor.d.ts +179 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/cache.d.ts +36 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/client-stats.d.ts +15 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/client.d.ts +123 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/connector.d.ts +36 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/content-type.d.ts +21 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/cookies.d.ts +30 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/dispatcher.d.ts +279 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/errors.d.ts +177 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/eventsource.d.ts +66 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/fetch.d.ts +211 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/formdata.d.ts +108 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/global-origin.d.ts +7 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/h2c-client.d.ts +73 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/handlers.d.ts +15 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/header.d.ts +160 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/index.d.ts +91 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/interceptors.d.ts +80 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/mock-agent.d.ts +68 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/mock-call-history.d.ts +111 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/mock-client.d.ts +27 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/mock-interceptor.d.ts +94 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/mock-pool.d.ts +27 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/package.json +55 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/patch.d.ts +29 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/pool.d.ts +41 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/proxy-agent.d.ts +29 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/readable.d.ts +68 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/retry-handler.d.ts +125 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/round-robin-pool.d.ts +41 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/snapshot-agent.d.ts +109 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/util.d.ts +18 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/utility.d.ts +7 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/webidl.d.ts +347 -0
- package/skills/adspecs-export-word/references/node_modules/undici-types/websocket.d.ts +188 -0
- package/skills/adspecs-export-word/references/node_modules/util-deprecate/History.md +16 -0
- package/skills/adspecs-export-word/references/node_modules/util-deprecate/LICENSE +24 -0
- package/skills/adspecs-export-word/references/node_modules/util-deprecate/README.md +53 -0
- package/skills/adspecs-export-word/references/node_modules/util-deprecate/browser.js +67 -0
- package/skills/adspecs-export-word/references/node_modules/util-deprecate/node.js +6 -0
- package/skills/adspecs-export-word/references/node_modules/util-deprecate/package.json +27 -0
- package/skills/adspecs-export-word/references/node_modules/xml/.travis.yml +8 -0
- package/skills/adspecs-export-word/references/node_modules/xml/LICENSE +22 -0
- package/skills/adspecs-export-word/references/node_modules/xml/examples/examples.js +81 -0
- package/skills/adspecs-export-word/references/node_modules/xml/examples/server.js +24 -0
- package/skills/adspecs-export-word/references/node_modules/xml/lib/escapeForXML.js +18 -0
- package/skills/adspecs-export-word/references/node_modules/xml/lib/xml.js +282 -0
- package/skills/adspecs-export-word/references/node_modules/xml/package.json +38 -0
- package/skills/adspecs-export-word/references/node_modules/xml/readme.md +184 -0
- package/skills/adspecs-export-word/references/node_modules/xml/test/xml.test.js +150 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/LICENSE +21 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/README.md +390 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/bin/cli-helper.js +47 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/bin/cli.js +83 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/bin/test.json +23 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/bin/test.xml +3 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/dist/xml-js.js +8310 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/dist/xml-js.min.js +8 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/index.js +1 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/lib/array-helper.js +11 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/lib/index.js +13 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/lib/js2xml.js +320 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/lib/json2xml.js +18 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/lib/options-helper.js +43 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/lib/xml2js.js +362 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/lib/xml2json.js +22 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/package.json +111 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/types/index.d.ts +154 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/types/tsconfig.json +14 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/types/typings.json +4 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/types/xml-js-tests.ts +60 -0
- package/skills/adspecs-export-word/references/node_modules/xml-js/webpack.config.js +28 -0
- package/skills/project-init/SKILL.md +10 -10
- package/src/commands/plugin.js +4 -4
- package/src/lib/readme-gen.js +1 -1
- package/src/lib/scaffolder.js +4 -3
- /package/skills/{adspecs-requirement-research → ads-requirement-research}/02-/351/234/200/346/261/202/346/235/245/346/272/220/344/270/216/351/207/207/351/233/206/350/256/260/345/275/225.md" +0 -0
|
@@ -0,0 +1,1848 @@
|
|
|
1
|
+
;(function (sax) {
|
|
2
|
+
// wrapper for non-node envs
|
|
3
|
+
sax.parser = function (strict, opt) {
|
|
4
|
+
return new SAXParser(strict, opt)
|
|
5
|
+
}
|
|
6
|
+
sax.SAXParser = SAXParser
|
|
7
|
+
sax.SAXStream = SAXStream
|
|
8
|
+
sax.createStream = createStream
|
|
9
|
+
|
|
10
|
+
// When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
|
|
11
|
+
// When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
|
|
12
|
+
// since that's the earliest that a buffer overrun could occur. This way, checks are
|
|
13
|
+
// as rare as required, but as often as necessary to ensure never crossing this bound.
|
|
14
|
+
// Furthermore, buffers are only tested at most once per write(), so passing a very
|
|
15
|
+
// large string into write() might have undesirable effects, but this is manageable by
|
|
16
|
+
// the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
|
|
17
|
+
// edge case, result in creating at most one complete copy of the string passed in.
|
|
18
|
+
// Set to Infinity to have unlimited buffers.
|
|
19
|
+
sax.MAX_BUFFER_LENGTH = 64 * 1024
|
|
20
|
+
|
|
21
|
+
var buffers = [
|
|
22
|
+
'comment',
|
|
23
|
+
'sgmlDecl',
|
|
24
|
+
'textNode',
|
|
25
|
+
'tagName',
|
|
26
|
+
'doctype',
|
|
27
|
+
'procInstName',
|
|
28
|
+
'procInstBody',
|
|
29
|
+
'entity',
|
|
30
|
+
'attribName',
|
|
31
|
+
'attribValue',
|
|
32
|
+
'cdata',
|
|
33
|
+
'script',
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
sax.EVENTS = [
|
|
37
|
+
'text',
|
|
38
|
+
'processinginstruction',
|
|
39
|
+
'sgmldeclaration',
|
|
40
|
+
'doctype',
|
|
41
|
+
'comment',
|
|
42
|
+
'opentagstart',
|
|
43
|
+
'attribute',
|
|
44
|
+
'opentag',
|
|
45
|
+
'closetag',
|
|
46
|
+
'opencdata',
|
|
47
|
+
'cdata',
|
|
48
|
+
'closecdata',
|
|
49
|
+
'error',
|
|
50
|
+
'end',
|
|
51
|
+
'ready',
|
|
52
|
+
'script',
|
|
53
|
+
'opennamespace',
|
|
54
|
+
'closenamespace',
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
function SAXParser(strict, opt) {
|
|
58
|
+
if (!(this instanceof SAXParser)) {
|
|
59
|
+
return new SAXParser(strict, opt)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var parser = this
|
|
63
|
+
clearBuffers(parser)
|
|
64
|
+
parser.q = parser.c = ''
|
|
65
|
+
parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
|
|
66
|
+
parser.encoding = null;
|
|
67
|
+
parser.opt = opt || {}
|
|
68
|
+
parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
|
|
69
|
+
parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'
|
|
70
|
+
parser.opt.maxEntityCount = parser.opt.maxEntityCount || 512
|
|
71
|
+
parser.opt.maxEntityDepth = parser.opt.maxEntityDepth || 4
|
|
72
|
+
parser.entityCount = parser.entityDepth = 0
|
|
73
|
+
parser.tags = []
|
|
74
|
+
parser.closed = parser.closedRoot = parser.sawRoot = false
|
|
75
|
+
parser.tag = parser.error = null
|
|
76
|
+
parser.strict = !!strict
|
|
77
|
+
parser.noscript = !!(strict || parser.opt.noscript)
|
|
78
|
+
parser.state = S.BEGIN
|
|
79
|
+
parser.strictEntities = parser.opt.strictEntities
|
|
80
|
+
parser.ENTITIES =
|
|
81
|
+
parser.strictEntities ?
|
|
82
|
+
Object.create(sax.XML_ENTITIES)
|
|
83
|
+
: Object.create(sax.ENTITIES)
|
|
84
|
+
parser.attribList = []
|
|
85
|
+
|
|
86
|
+
// namespaces form a prototype chain.
|
|
87
|
+
// it always points at the current tag,
|
|
88
|
+
// which protos to its parent tag.
|
|
89
|
+
if (parser.opt.xmlns) {
|
|
90
|
+
parser.ns = Object.create(rootNS)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// disallow unquoted attribute values if not otherwise configured
|
|
94
|
+
// and strict mode is true
|
|
95
|
+
if (parser.opt.unquotedAttributeValues === undefined) {
|
|
96
|
+
parser.opt.unquotedAttributeValues = !strict
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// mostly just for error reporting
|
|
100
|
+
parser.trackPosition = parser.opt.position !== false
|
|
101
|
+
if (parser.trackPosition) {
|
|
102
|
+
parser.position = parser.line = parser.column = 0
|
|
103
|
+
}
|
|
104
|
+
emit(parser, 'onready')
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!Object.create) {
|
|
108
|
+
Object.create = function (o) {
|
|
109
|
+
function F() {}
|
|
110
|
+
F.prototype = o
|
|
111
|
+
var newf = new F()
|
|
112
|
+
return newf
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!Object.keys) {
|
|
117
|
+
Object.keys = function (o) {
|
|
118
|
+
var a = []
|
|
119
|
+
for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
|
|
120
|
+
return a
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function checkBufferLength(parser) {
|
|
125
|
+
var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
|
|
126
|
+
var maxActual = 0
|
|
127
|
+
for (var i = 0, l = buffers.length; i < l; i++) {
|
|
128
|
+
var len = parser[buffers[i]].length
|
|
129
|
+
if (len > maxAllowed) {
|
|
130
|
+
// Text/cdata nodes can get big, and since they're buffered,
|
|
131
|
+
// we can get here under normal conditions.
|
|
132
|
+
// Avoid issues by emitting the text node now,
|
|
133
|
+
// so at least it won't get any bigger.
|
|
134
|
+
switch (buffers[i]) {
|
|
135
|
+
case 'textNode':
|
|
136
|
+
closeText(parser)
|
|
137
|
+
break
|
|
138
|
+
|
|
139
|
+
case 'cdata':
|
|
140
|
+
emitNode(parser, 'oncdata', parser.cdata)
|
|
141
|
+
parser.cdata = ''
|
|
142
|
+
break
|
|
143
|
+
|
|
144
|
+
case 'script':
|
|
145
|
+
emitNode(parser, 'onscript', parser.script)
|
|
146
|
+
parser.script = ''
|
|
147
|
+
break
|
|
148
|
+
|
|
149
|
+
default:
|
|
150
|
+
error(parser, 'Max buffer length exceeded: ' + buffers[i])
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
maxActual = Math.max(maxActual, len)
|
|
154
|
+
}
|
|
155
|
+
// schedule the next check for the earliest possible buffer overrun.
|
|
156
|
+
var m = sax.MAX_BUFFER_LENGTH - maxActual
|
|
157
|
+
parser.bufferCheckPosition = m + parser.position
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function clearBuffers(parser) {
|
|
161
|
+
for (var i = 0, l = buffers.length; i < l; i++) {
|
|
162
|
+
parser[buffers[i]] = ''
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function flushBuffers(parser) {
|
|
167
|
+
closeText(parser)
|
|
168
|
+
if (parser.cdata !== '') {
|
|
169
|
+
emitNode(parser, 'oncdata', parser.cdata)
|
|
170
|
+
parser.cdata = ''
|
|
171
|
+
}
|
|
172
|
+
if (parser.script !== '') {
|
|
173
|
+
emitNode(parser, 'onscript', parser.script)
|
|
174
|
+
parser.script = ''
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
SAXParser.prototype = {
|
|
179
|
+
end: function () {
|
|
180
|
+
end(this)
|
|
181
|
+
},
|
|
182
|
+
write: write,
|
|
183
|
+
resume: function () {
|
|
184
|
+
this.error = null
|
|
185
|
+
return this
|
|
186
|
+
},
|
|
187
|
+
close: function () {
|
|
188
|
+
return this.write(null)
|
|
189
|
+
},
|
|
190
|
+
flush: function () {
|
|
191
|
+
flushBuffers(this)
|
|
192
|
+
},
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
var Stream
|
|
196
|
+
try {
|
|
197
|
+
Stream = require('stream').Stream
|
|
198
|
+
} catch (ex) {
|
|
199
|
+
Stream = function () {}
|
|
200
|
+
}
|
|
201
|
+
if (!Stream) Stream = function () {}
|
|
202
|
+
|
|
203
|
+
var streamWraps = sax.EVENTS.filter(function (ev) {
|
|
204
|
+
return ev !== 'error' && ev !== 'end'
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
function createStream(strict, opt) {
|
|
208
|
+
return new SAXStream(strict, opt)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function determineBufferEncoding(data, isEnd) {
|
|
212
|
+
// BOM-based detection is the most reliable signal when present.
|
|
213
|
+
if (data.length >= 2) {
|
|
214
|
+
if (data[0] === 0xff && data[1] === 0xfe) {
|
|
215
|
+
return 'utf-16le'
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (data[0] === 0xfe && data[1] === 0xff) {
|
|
219
|
+
return 'utf-16be'
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (data.length >= 3 && data[0] === 0xef && data[1] === 0xbb && data[2] === 0xbf) {
|
|
224
|
+
return 'utf8'
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (data.length >= 4) {
|
|
228
|
+
// XML documents without a BOM still start with "<?xml", which is enough
|
|
229
|
+
// to distinguish UTF-16LE/BE from UTF-8 by looking at the zero bytes.
|
|
230
|
+
if (data[0] === 0x3c && data[1] === 0x00 && data[2] === 0x3f && data[3] === 0x00) {
|
|
231
|
+
return 'utf-16le'
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (data[0] === 0x00 && data[1] === 0x3c && data[2] === 0x00 && data[3] === 0x3f) {
|
|
235
|
+
return 'utf-16be'
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return 'utf8'
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return isEnd ? 'utf8' : null
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function SAXStream(strict, opt) {
|
|
245
|
+
if (!(this instanceof SAXStream)) {
|
|
246
|
+
return new SAXStream(strict, opt)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
Stream.apply(this)
|
|
250
|
+
|
|
251
|
+
this._parser = new SAXParser(strict, opt)
|
|
252
|
+
this.writable = true
|
|
253
|
+
this.readable = true
|
|
254
|
+
|
|
255
|
+
var me = this
|
|
256
|
+
|
|
257
|
+
this._parser.onend = function () {
|
|
258
|
+
me.emit('end')
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
this._parser.onerror = function (er) {
|
|
262
|
+
me.emit('error', er)
|
|
263
|
+
|
|
264
|
+
// if didn't throw, then means error was handled.
|
|
265
|
+
// go ahead and clear error, so we can write again.
|
|
266
|
+
me._parser.error = null
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
this._decoder = null
|
|
270
|
+
this._decoderBuffer = null
|
|
271
|
+
streamWraps.forEach(function (ev) {
|
|
272
|
+
Object.defineProperty(me, 'on' + ev, {
|
|
273
|
+
get: function () {
|
|
274
|
+
return me._parser['on' + ev]
|
|
275
|
+
},
|
|
276
|
+
set: function (h) {
|
|
277
|
+
if (!h) {
|
|
278
|
+
me.removeAllListeners(ev)
|
|
279
|
+
me._parser['on' + ev] = h
|
|
280
|
+
return h
|
|
281
|
+
}
|
|
282
|
+
me.on(ev, h)
|
|
283
|
+
},
|
|
284
|
+
enumerable: true,
|
|
285
|
+
configurable: false,
|
|
286
|
+
})
|
|
287
|
+
})
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
SAXStream.prototype = Object.create(Stream.prototype, {
|
|
291
|
+
constructor: {
|
|
292
|
+
value: SAXStream,
|
|
293
|
+
},
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
SAXStream.prototype._decodeBuffer = function (data, isEnd) {
|
|
297
|
+
if (this._decoderBuffer) {
|
|
298
|
+
// Keep incomplete leading bytes until we have enough data to infer the
|
|
299
|
+
// stream encoding, then decode the buffered prefix together with the next chunk.
|
|
300
|
+
data = Buffer.concat([this._decoderBuffer, data])
|
|
301
|
+
this._decoderBuffer = null
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (!this._decoder) {
|
|
305
|
+
var encoding = determineBufferEncoding(data, isEnd)
|
|
306
|
+
if (!encoding) {
|
|
307
|
+
// A very short first chunk may not contain enough bytes to detect the
|
|
308
|
+
// encoding yet, so defer decoding until the next write/end call.
|
|
309
|
+
this._decoderBuffer = data
|
|
310
|
+
return ''
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Store the detected transport encoding so strict mode can compare it
|
|
314
|
+
// with the optional encoding declared in the XML prolog later on.
|
|
315
|
+
this._parser.encoding = encoding
|
|
316
|
+
this._decoder = new TextDecoder(encoding)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return this._decoder.decode(data, { stream: !isEnd })
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
SAXStream.prototype.write = function (data) {
|
|
323
|
+
if (
|
|
324
|
+
typeof Buffer === 'function' &&
|
|
325
|
+
typeof Buffer.isBuffer === 'function' &&
|
|
326
|
+
Buffer.isBuffer(data)
|
|
327
|
+
) {
|
|
328
|
+
data = this._decodeBuffer(data, false)
|
|
329
|
+
} else if (this._decoderBuffer) {
|
|
330
|
+
// Flush any buffered binary prefix before handling a string chunk.
|
|
331
|
+
// This only matters if the caller mixes Buffer and string writes (used in test).
|
|
332
|
+
var remaining = this._decodeBuffer(Buffer.alloc(0), true)
|
|
333
|
+
if (remaining) {
|
|
334
|
+
this._parser.write(remaining)
|
|
335
|
+
this.emit('data', remaining)
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
this._parser.write(data.toString())
|
|
340
|
+
this.emit('data', data)
|
|
341
|
+
return true
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
SAXStream.prototype.end = function (chunk) {
|
|
345
|
+
if (chunk && chunk.length) {
|
|
346
|
+
this.write(chunk)
|
|
347
|
+
}
|
|
348
|
+
// Flush any remaining decoded data from the TextDecoder
|
|
349
|
+
if (this._decoderBuffer) {
|
|
350
|
+
var finalChunk = this._decodeBuffer(Buffer.alloc(0), true)
|
|
351
|
+
if (finalChunk) {
|
|
352
|
+
this._parser.write(finalChunk)
|
|
353
|
+
this.emit('data', finalChunk)
|
|
354
|
+
}
|
|
355
|
+
} else if (this._decoder) {
|
|
356
|
+
var remaining = this._decoder.decode()
|
|
357
|
+
if (remaining) {
|
|
358
|
+
this._parser.write(remaining)
|
|
359
|
+
this.emit('data', remaining)
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
this._parser.end()
|
|
363
|
+
return true
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
SAXStream.prototype.on = function (ev, handler) {
|
|
367
|
+
var me = this
|
|
368
|
+
if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
|
|
369
|
+
me._parser['on' + ev] = function () {
|
|
370
|
+
var args =
|
|
371
|
+
arguments.length === 1 ?
|
|
372
|
+
[arguments[0]]
|
|
373
|
+
: Array.apply(null, arguments)
|
|
374
|
+
args.splice(0, 0, ev)
|
|
375
|
+
me.emit.apply(me, args)
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return Stream.prototype.on.call(me, ev, handler)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// this really needs to be replaced with character classes.
|
|
383
|
+
// XML allows all manner of ridiculous numbers and digits.
|
|
384
|
+
var CDATA = '[CDATA['
|
|
385
|
+
var DOCTYPE = 'DOCTYPE'
|
|
386
|
+
var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'
|
|
387
|
+
var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'
|
|
388
|
+
var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
|
|
389
|
+
|
|
390
|
+
// http://www.w3.org/TR/REC-xml/#NT-NameStartChar
|
|
391
|
+
// This implementation works on strings, a single character at a time
|
|
392
|
+
// as such, it cannot ever support astral-plane characters (10000-EFFFF)
|
|
393
|
+
// without a significant breaking change to either this parser, or the
|
|
394
|
+
// JavaScript language. Implementation of an emoji-capable xml parser
|
|
395
|
+
// is left as an exercise for the reader.
|
|
396
|
+
var nameStart =
|
|
397
|
+
/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
|
|
398
|
+
|
|
399
|
+
var nameBody =
|
|
400
|
+
/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
|
|
401
|
+
|
|
402
|
+
var entityStart =
|
|
403
|
+
/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
|
|
404
|
+
var entityBody =
|
|
405
|
+
/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
|
|
406
|
+
|
|
407
|
+
function isWhitespace(c) {
|
|
408
|
+
return c === ' ' || c === '\n' || c === '\r' || c === '\t'
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function isQuote(c) {
|
|
412
|
+
return c === '"' || c === "'"
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function isAttribEnd(c) {
|
|
416
|
+
return c === '>' || isWhitespace(c)
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function isMatch(regex, c) {
|
|
420
|
+
return regex.test(c)
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function notMatch(regex, c) {
|
|
424
|
+
return !isMatch(regex, c)
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
var S = 0
|
|
428
|
+
sax.STATE = {
|
|
429
|
+
BEGIN: S++, // leading byte order mark or whitespace
|
|
430
|
+
BEGIN_WHITESPACE: S++, // leading whitespace
|
|
431
|
+
TEXT: S++, // general stuff
|
|
432
|
+
TEXT_ENTITY: S++, // & and such.
|
|
433
|
+
OPEN_WAKA: S++, // <
|
|
434
|
+
SGML_DECL: S++, // <!BLARG
|
|
435
|
+
SGML_DECL_QUOTED: S++, // <!BLARG foo "bar
|
|
436
|
+
DOCTYPE: S++, // <!DOCTYPE
|
|
437
|
+
DOCTYPE_QUOTED: S++, // <!DOCTYPE "//blah
|
|
438
|
+
DOCTYPE_DTD: S++, // <!DOCTYPE "//blah" [ ...
|
|
439
|
+
DOCTYPE_DTD_QUOTED: S++, // <!DOCTYPE "//blah" [ "foo
|
|
440
|
+
COMMENT_STARTING: S++, // <!-
|
|
441
|
+
COMMENT: S++, // <!--
|
|
442
|
+
COMMENT_ENDING: S++, // <!-- blah -
|
|
443
|
+
COMMENT_ENDED: S++, // <!-- blah --
|
|
444
|
+
CDATA: S++, // <![CDATA[ something
|
|
445
|
+
CDATA_ENDING: S++, // ]
|
|
446
|
+
CDATA_ENDING_2: S++, // ]]
|
|
447
|
+
PROC_INST: S++, // <?hi
|
|
448
|
+
PROC_INST_BODY: S++, // <?hi there
|
|
449
|
+
PROC_INST_ENDING: S++, // <?hi "there" ?
|
|
450
|
+
OPEN_TAG: S++, // <strong
|
|
451
|
+
OPEN_TAG_SLASH: S++, // <strong /
|
|
452
|
+
ATTRIB: S++, // <a
|
|
453
|
+
ATTRIB_NAME: S++, // <a foo
|
|
454
|
+
ATTRIB_NAME_SAW_WHITE: S++, // <a foo _
|
|
455
|
+
ATTRIB_VALUE: S++, // <a foo=
|
|
456
|
+
ATTRIB_VALUE_QUOTED: S++, // <a foo="bar
|
|
457
|
+
ATTRIB_VALUE_CLOSED: S++, // <a foo="bar"
|
|
458
|
+
ATTRIB_VALUE_UNQUOTED: S++, // <a foo=bar
|
|
459
|
+
ATTRIB_VALUE_ENTITY_Q: S++, // <foo bar="""
|
|
460
|
+
ATTRIB_VALUE_ENTITY_U: S++, // <foo bar="
|
|
461
|
+
CLOSE_TAG: S++, // </a
|
|
462
|
+
CLOSE_TAG_SAW_WHITE: S++, // </a >
|
|
463
|
+
SCRIPT: S++, // <script> ...
|
|
464
|
+
SCRIPT_ENDING: S++, // <script> ... <
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
sax.XML_ENTITIES = {
|
|
468
|
+
amp: '&',
|
|
469
|
+
gt: '>',
|
|
470
|
+
lt: '<',
|
|
471
|
+
quot: '"',
|
|
472
|
+
apos: "'",
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
sax.ENTITIES = {
|
|
476
|
+
amp: '&',
|
|
477
|
+
gt: '>',
|
|
478
|
+
lt: '<',
|
|
479
|
+
quot: '"',
|
|
480
|
+
apos: "'",
|
|
481
|
+
AElig: 198,
|
|
482
|
+
Aacute: 193,
|
|
483
|
+
Acirc: 194,
|
|
484
|
+
Agrave: 192,
|
|
485
|
+
Aring: 197,
|
|
486
|
+
Atilde: 195,
|
|
487
|
+
Auml: 196,
|
|
488
|
+
Ccedil: 199,
|
|
489
|
+
ETH: 208,
|
|
490
|
+
Eacute: 201,
|
|
491
|
+
Ecirc: 202,
|
|
492
|
+
Egrave: 200,
|
|
493
|
+
Euml: 203,
|
|
494
|
+
Iacute: 205,
|
|
495
|
+
Icirc: 206,
|
|
496
|
+
Igrave: 204,
|
|
497
|
+
Iuml: 207,
|
|
498
|
+
Ntilde: 209,
|
|
499
|
+
Oacute: 211,
|
|
500
|
+
Ocirc: 212,
|
|
501
|
+
Ograve: 210,
|
|
502
|
+
Oslash: 216,
|
|
503
|
+
Otilde: 213,
|
|
504
|
+
Ouml: 214,
|
|
505
|
+
THORN: 222,
|
|
506
|
+
Uacute: 218,
|
|
507
|
+
Ucirc: 219,
|
|
508
|
+
Ugrave: 217,
|
|
509
|
+
Uuml: 220,
|
|
510
|
+
Yacute: 221,
|
|
511
|
+
aacute: 225,
|
|
512
|
+
acirc: 226,
|
|
513
|
+
aelig: 230,
|
|
514
|
+
agrave: 224,
|
|
515
|
+
aring: 229,
|
|
516
|
+
atilde: 227,
|
|
517
|
+
auml: 228,
|
|
518
|
+
ccedil: 231,
|
|
519
|
+
eacute: 233,
|
|
520
|
+
ecirc: 234,
|
|
521
|
+
egrave: 232,
|
|
522
|
+
eth: 240,
|
|
523
|
+
euml: 235,
|
|
524
|
+
iacute: 237,
|
|
525
|
+
icirc: 238,
|
|
526
|
+
igrave: 236,
|
|
527
|
+
iuml: 239,
|
|
528
|
+
ntilde: 241,
|
|
529
|
+
oacute: 243,
|
|
530
|
+
ocirc: 244,
|
|
531
|
+
ograve: 242,
|
|
532
|
+
oslash: 248,
|
|
533
|
+
otilde: 245,
|
|
534
|
+
ouml: 246,
|
|
535
|
+
szlig: 223,
|
|
536
|
+
thorn: 254,
|
|
537
|
+
uacute: 250,
|
|
538
|
+
ucirc: 251,
|
|
539
|
+
ugrave: 249,
|
|
540
|
+
uuml: 252,
|
|
541
|
+
yacute: 253,
|
|
542
|
+
yuml: 255,
|
|
543
|
+
copy: 169,
|
|
544
|
+
reg: 174,
|
|
545
|
+
nbsp: 160,
|
|
546
|
+
iexcl: 161,
|
|
547
|
+
cent: 162,
|
|
548
|
+
pound: 163,
|
|
549
|
+
curren: 164,
|
|
550
|
+
yen: 165,
|
|
551
|
+
brvbar: 166,
|
|
552
|
+
sect: 167,
|
|
553
|
+
uml: 168,
|
|
554
|
+
ordf: 170,
|
|
555
|
+
laquo: 171,
|
|
556
|
+
not: 172,
|
|
557
|
+
shy: 173,
|
|
558
|
+
macr: 175,
|
|
559
|
+
deg: 176,
|
|
560
|
+
plusmn: 177,
|
|
561
|
+
sup1: 185,
|
|
562
|
+
sup2: 178,
|
|
563
|
+
sup3: 179,
|
|
564
|
+
acute: 180,
|
|
565
|
+
micro: 181,
|
|
566
|
+
para: 182,
|
|
567
|
+
middot: 183,
|
|
568
|
+
cedil: 184,
|
|
569
|
+
ordm: 186,
|
|
570
|
+
raquo: 187,
|
|
571
|
+
frac14: 188,
|
|
572
|
+
frac12: 189,
|
|
573
|
+
frac34: 190,
|
|
574
|
+
iquest: 191,
|
|
575
|
+
times: 215,
|
|
576
|
+
divide: 247,
|
|
577
|
+
OElig: 338,
|
|
578
|
+
oelig: 339,
|
|
579
|
+
Scaron: 352,
|
|
580
|
+
scaron: 353,
|
|
581
|
+
Yuml: 376,
|
|
582
|
+
fnof: 402,
|
|
583
|
+
circ: 710,
|
|
584
|
+
tilde: 732,
|
|
585
|
+
Alpha: 913,
|
|
586
|
+
Beta: 914,
|
|
587
|
+
Gamma: 915,
|
|
588
|
+
Delta: 916,
|
|
589
|
+
Epsilon: 917,
|
|
590
|
+
Zeta: 918,
|
|
591
|
+
Eta: 919,
|
|
592
|
+
Theta: 920,
|
|
593
|
+
Iota: 921,
|
|
594
|
+
Kappa: 922,
|
|
595
|
+
Lambda: 923,
|
|
596
|
+
Mu: 924,
|
|
597
|
+
Nu: 925,
|
|
598
|
+
Xi: 926,
|
|
599
|
+
Omicron: 927,
|
|
600
|
+
Pi: 928,
|
|
601
|
+
Rho: 929,
|
|
602
|
+
Sigma: 931,
|
|
603
|
+
Tau: 932,
|
|
604
|
+
Upsilon: 933,
|
|
605
|
+
Phi: 934,
|
|
606
|
+
Chi: 935,
|
|
607
|
+
Psi: 936,
|
|
608
|
+
Omega: 937,
|
|
609
|
+
alpha: 945,
|
|
610
|
+
beta: 946,
|
|
611
|
+
gamma: 947,
|
|
612
|
+
delta: 948,
|
|
613
|
+
epsilon: 949,
|
|
614
|
+
zeta: 950,
|
|
615
|
+
eta: 951,
|
|
616
|
+
theta: 952,
|
|
617
|
+
iota: 953,
|
|
618
|
+
kappa: 954,
|
|
619
|
+
lambda: 955,
|
|
620
|
+
mu: 956,
|
|
621
|
+
nu: 957,
|
|
622
|
+
xi: 958,
|
|
623
|
+
omicron: 959,
|
|
624
|
+
pi: 960,
|
|
625
|
+
rho: 961,
|
|
626
|
+
sigmaf: 962,
|
|
627
|
+
sigma: 963,
|
|
628
|
+
tau: 964,
|
|
629
|
+
upsilon: 965,
|
|
630
|
+
phi: 966,
|
|
631
|
+
chi: 967,
|
|
632
|
+
psi: 968,
|
|
633
|
+
omega: 969,
|
|
634
|
+
thetasym: 977,
|
|
635
|
+
upsih: 978,
|
|
636
|
+
piv: 982,
|
|
637
|
+
ensp: 8194,
|
|
638
|
+
emsp: 8195,
|
|
639
|
+
thinsp: 8201,
|
|
640
|
+
zwnj: 8204,
|
|
641
|
+
zwj: 8205,
|
|
642
|
+
lrm: 8206,
|
|
643
|
+
rlm: 8207,
|
|
644
|
+
ndash: 8211,
|
|
645
|
+
mdash: 8212,
|
|
646
|
+
lsquo: 8216,
|
|
647
|
+
rsquo: 8217,
|
|
648
|
+
sbquo: 8218,
|
|
649
|
+
ldquo: 8220,
|
|
650
|
+
rdquo: 8221,
|
|
651
|
+
bdquo: 8222,
|
|
652
|
+
dagger: 8224,
|
|
653
|
+
Dagger: 8225,
|
|
654
|
+
bull: 8226,
|
|
655
|
+
hellip: 8230,
|
|
656
|
+
permil: 8240,
|
|
657
|
+
prime: 8242,
|
|
658
|
+
Prime: 8243,
|
|
659
|
+
lsaquo: 8249,
|
|
660
|
+
rsaquo: 8250,
|
|
661
|
+
oline: 8254,
|
|
662
|
+
frasl: 8260,
|
|
663
|
+
euro: 8364,
|
|
664
|
+
image: 8465,
|
|
665
|
+
weierp: 8472,
|
|
666
|
+
real: 8476,
|
|
667
|
+
trade: 8482,
|
|
668
|
+
alefsym: 8501,
|
|
669
|
+
larr: 8592,
|
|
670
|
+
uarr: 8593,
|
|
671
|
+
rarr: 8594,
|
|
672
|
+
darr: 8595,
|
|
673
|
+
harr: 8596,
|
|
674
|
+
crarr: 8629,
|
|
675
|
+
lArr: 8656,
|
|
676
|
+
uArr: 8657,
|
|
677
|
+
rArr: 8658,
|
|
678
|
+
dArr: 8659,
|
|
679
|
+
hArr: 8660,
|
|
680
|
+
forall: 8704,
|
|
681
|
+
part: 8706,
|
|
682
|
+
exist: 8707,
|
|
683
|
+
empty: 8709,
|
|
684
|
+
nabla: 8711,
|
|
685
|
+
isin: 8712,
|
|
686
|
+
notin: 8713,
|
|
687
|
+
ni: 8715,
|
|
688
|
+
prod: 8719,
|
|
689
|
+
sum: 8721,
|
|
690
|
+
minus: 8722,
|
|
691
|
+
lowast: 8727,
|
|
692
|
+
radic: 8730,
|
|
693
|
+
prop: 8733,
|
|
694
|
+
infin: 8734,
|
|
695
|
+
ang: 8736,
|
|
696
|
+
and: 8743,
|
|
697
|
+
or: 8744,
|
|
698
|
+
cap: 8745,
|
|
699
|
+
cup: 8746,
|
|
700
|
+
int: 8747,
|
|
701
|
+
there4: 8756,
|
|
702
|
+
sim: 8764,
|
|
703
|
+
cong: 8773,
|
|
704
|
+
asymp: 8776,
|
|
705
|
+
ne: 8800,
|
|
706
|
+
equiv: 8801,
|
|
707
|
+
le: 8804,
|
|
708
|
+
ge: 8805,
|
|
709
|
+
sub: 8834,
|
|
710
|
+
sup: 8835,
|
|
711
|
+
nsub: 8836,
|
|
712
|
+
sube: 8838,
|
|
713
|
+
supe: 8839,
|
|
714
|
+
oplus: 8853,
|
|
715
|
+
otimes: 8855,
|
|
716
|
+
perp: 8869,
|
|
717
|
+
sdot: 8901,
|
|
718
|
+
lceil: 8968,
|
|
719
|
+
rceil: 8969,
|
|
720
|
+
lfloor: 8970,
|
|
721
|
+
rfloor: 8971,
|
|
722
|
+
lang: 9001,
|
|
723
|
+
rang: 9002,
|
|
724
|
+
loz: 9674,
|
|
725
|
+
spades: 9824,
|
|
726
|
+
clubs: 9827,
|
|
727
|
+
hearts: 9829,
|
|
728
|
+
diams: 9830,
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
Object.keys(sax.ENTITIES).forEach(function (key) {
|
|
732
|
+
var e = sax.ENTITIES[key]
|
|
733
|
+
var s = typeof e === 'number' ? String.fromCharCode(e) : e
|
|
734
|
+
sax.ENTITIES[key] = s
|
|
735
|
+
})
|
|
736
|
+
|
|
737
|
+
for (var s in sax.STATE) {
|
|
738
|
+
sax.STATE[sax.STATE[s]] = s
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
// shorthand
|
|
742
|
+
S = sax.STATE
|
|
743
|
+
|
|
744
|
+
function emit(parser, event, data) {
|
|
745
|
+
parser[event] && parser[event](data)
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
function getDeclaredEncoding(body) {
|
|
749
|
+
var match = body && body.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i)
|
|
750
|
+
return match ? match[2] : null
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function normalizeEncodingName(encoding) {
|
|
754
|
+
if (!encoding) {
|
|
755
|
+
return null
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
return encoding.toLowerCase().replace(/[^a-z0-9]/g, '')
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
function encodingsMatch(detectedEncoding, declaredEncoding) {
|
|
762
|
+
const detected = normalizeEncodingName(detectedEncoding)
|
|
763
|
+
const declared = normalizeEncodingName(declaredEncoding)
|
|
764
|
+
|
|
765
|
+
if (!detected || !declared) {
|
|
766
|
+
return true
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
if (declared === 'utf16') {
|
|
770
|
+
return detected === 'utf16le' || detected === 'utf16be'
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
return detected === declared
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
function validateXmlDeclarationEncoding(parser, data) {
|
|
777
|
+
if (
|
|
778
|
+
!parser.strict ||
|
|
779
|
+
!parser.encoding ||
|
|
780
|
+
!data ||
|
|
781
|
+
data.name !== 'xml'
|
|
782
|
+
) {
|
|
783
|
+
return
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
var declaredEncoding = getDeclaredEncoding(data.body)
|
|
787
|
+
if (
|
|
788
|
+
declaredEncoding &&
|
|
789
|
+
!encodingsMatch(parser.encoding, declaredEncoding)
|
|
790
|
+
) {
|
|
791
|
+
strictFail(
|
|
792
|
+
parser,
|
|
793
|
+
'XML declaration encoding ' +
|
|
794
|
+
declaredEncoding +
|
|
795
|
+
' does not match detected stream encoding ' +
|
|
796
|
+
parser.encoding.toUpperCase()
|
|
797
|
+
)
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
function emitNode(parser, nodeType, data) {
|
|
802
|
+
if (parser.textNode) closeText(parser)
|
|
803
|
+
emit(parser, nodeType, data)
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
function closeText(parser) {
|
|
807
|
+
parser.textNode = textopts(parser.opt, parser.textNode)
|
|
808
|
+
if (parser.textNode) emit(parser, 'ontext', parser.textNode)
|
|
809
|
+
parser.textNode = ''
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
function textopts(opt, text) {
|
|
813
|
+
if (opt.trim) text = text.trim()
|
|
814
|
+
if (opt.normalize) text = text.replace(/\s+/g, ' ')
|
|
815
|
+
return text
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function error(parser, er) {
|
|
819
|
+
closeText(parser)
|
|
820
|
+
if (parser.trackPosition) {
|
|
821
|
+
er +=
|
|
822
|
+
'\nLine: ' +
|
|
823
|
+
parser.line +
|
|
824
|
+
'\nColumn: ' +
|
|
825
|
+
parser.column +
|
|
826
|
+
'\nChar: ' +
|
|
827
|
+
parser.c
|
|
828
|
+
}
|
|
829
|
+
er = new Error(er)
|
|
830
|
+
parser.error = er
|
|
831
|
+
emit(parser, 'onerror', er)
|
|
832
|
+
return parser
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
function end(parser) {
|
|
836
|
+
if (parser.sawRoot && !parser.closedRoot)
|
|
837
|
+
strictFail(parser, 'Unclosed root tag')
|
|
838
|
+
if (
|
|
839
|
+
parser.state !== S.BEGIN &&
|
|
840
|
+
parser.state !== S.BEGIN_WHITESPACE &&
|
|
841
|
+
parser.state !== S.TEXT
|
|
842
|
+
) {
|
|
843
|
+
error(parser, 'Unexpected end')
|
|
844
|
+
}
|
|
845
|
+
closeText(parser)
|
|
846
|
+
parser.c = ''
|
|
847
|
+
parser.closed = true
|
|
848
|
+
emit(parser, 'onend')
|
|
849
|
+
SAXParser.call(parser, parser.strict, parser.opt)
|
|
850
|
+
return parser
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function strictFail(parser, message) {
|
|
854
|
+
if (typeof parser !== 'object' || !(parser instanceof SAXParser)) {
|
|
855
|
+
throw new Error('bad call to strictFail')
|
|
856
|
+
}
|
|
857
|
+
if (parser.strict) {
|
|
858
|
+
error(parser, message)
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
function newTag(parser) {
|
|
863
|
+
if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()
|
|
864
|
+
var parent = parser.tags[parser.tags.length - 1] || parser
|
|
865
|
+
var tag = (parser.tag = { name: parser.tagName, attributes: {} })
|
|
866
|
+
|
|
867
|
+
// will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
|
|
868
|
+
if (parser.opt.xmlns) {
|
|
869
|
+
tag.ns = parent.ns
|
|
870
|
+
}
|
|
871
|
+
parser.attribList.length = 0
|
|
872
|
+
emitNode(parser, 'onopentagstart', tag)
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
function qname(name, attribute) {
|
|
876
|
+
var i = name.indexOf(':')
|
|
877
|
+
var qualName = i < 0 ? ['', name] : name.split(':')
|
|
878
|
+
var prefix = qualName[0]
|
|
879
|
+
var local = qualName[1]
|
|
880
|
+
|
|
881
|
+
// <x "xmlns"="http://foo">
|
|
882
|
+
if (attribute && name === 'xmlns') {
|
|
883
|
+
prefix = 'xmlns'
|
|
884
|
+
local = ''
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
return { prefix: prefix, local: local }
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
function attrib(parser) {
|
|
891
|
+
if (!parser.strict) {
|
|
892
|
+
parser.attribName = parser.attribName[parser.looseCase]()
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
if (
|
|
896
|
+
parser.attribList.indexOf(parser.attribName) !== -1 ||
|
|
897
|
+
parser.tag.attributes.hasOwnProperty(parser.attribName)
|
|
898
|
+
) {
|
|
899
|
+
parser.attribName = parser.attribValue = ''
|
|
900
|
+
return
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
if (parser.opt.xmlns) {
|
|
904
|
+
var qn = qname(parser.attribName, true)
|
|
905
|
+
var prefix = qn.prefix
|
|
906
|
+
var local = qn.local
|
|
907
|
+
|
|
908
|
+
if (prefix === 'xmlns') {
|
|
909
|
+
// namespace binding attribute. push the binding into scope
|
|
910
|
+
if (local === 'xml' && parser.attribValue !== XML_NAMESPACE) {
|
|
911
|
+
strictFail(
|
|
912
|
+
parser,
|
|
913
|
+
'xml: prefix must be bound to ' +
|
|
914
|
+
XML_NAMESPACE +
|
|
915
|
+
'\n' +
|
|
916
|
+
'Actual: ' +
|
|
917
|
+
parser.attribValue
|
|
918
|
+
)
|
|
919
|
+
} else if (
|
|
920
|
+
local === 'xmlns' &&
|
|
921
|
+
parser.attribValue !== XMLNS_NAMESPACE
|
|
922
|
+
) {
|
|
923
|
+
strictFail(
|
|
924
|
+
parser,
|
|
925
|
+
'xmlns: prefix must be bound to ' +
|
|
926
|
+
XMLNS_NAMESPACE +
|
|
927
|
+
'\n' +
|
|
928
|
+
'Actual: ' +
|
|
929
|
+
parser.attribValue
|
|
930
|
+
)
|
|
931
|
+
} else {
|
|
932
|
+
var tag = parser.tag
|
|
933
|
+
var parent = parser.tags[parser.tags.length - 1] || parser
|
|
934
|
+
if (tag.ns === parent.ns) {
|
|
935
|
+
tag.ns = Object.create(parent.ns)
|
|
936
|
+
}
|
|
937
|
+
tag.ns[local] = parser.attribValue
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
// defer onattribute events until all attributes have been seen
|
|
942
|
+
// so any new bindings can take effect. preserve attribute order
|
|
943
|
+
// so deferred events can be emitted in document order
|
|
944
|
+
parser.attribList.push([parser.attribName, parser.attribValue])
|
|
945
|
+
} else {
|
|
946
|
+
// in non-xmlns mode, we can emit the event right away
|
|
947
|
+
parser.tag.attributes[parser.attribName] = parser.attribValue
|
|
948
|
+
emitNode(parser, 'onattribute', {
|
|
949
|
+
name: parser.attribName,
|
|
950
|
+
value: parser.attribValue,
|
|
951
|
+
})
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
parser.attribName = parser.attribValue = ''
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
function openTag(parser, selfClosing) {
|
|
958
|
+
if (parser.opt.xmlns) {
|
|
959
|
+
// emit namespace binding events
|
|
960
|
+
var tag = parser.tag
|
|
961
|
+
|
|
962
|
+
// add namespace info to tag
|
|
963
|
+
var qn = qname(parser.tagName)
|
|
964
|
+
tag.prefix = qn.prefix
|
|
965
|
+
tag.local = qn.local
|
|
966
|
+
tag.uri = tag.ns[qn.prefix] || ''
|
|
967
|
+
|
|
968
|
+
if (tag.prefix && !tag.uri) {
|
|
969
|
+
strictFail(
|
|
970
|
+
parser,
|
|
971
|
+
'Unbound namespace prefix: ' + JSON.stringify(parser.tagName)
|
|
972
|
+
)
|
|
973
|
+
tag.uri = qn.prefix
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
var parent = parser.tags[parser.tags.length - 1] || parser
|
|
977
|
+
if (tag.ns && parent.ns !== tag.ns) {
|
|
978
|
+
Object.keys(tag.ns).forEach(function (p) {
|
|
979
|
+
emitNode(parser, 'onopennamespace', {
|
|
980
|
+
prefix: p,
|
|
981
|
+
uri: tag.ns[p],
|
|
982
|
+
})
|
|
983
|
+
})
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
// handle deferred onattribute events
|
|
987
|
+
// Note: do not apply default ns to attributes:
|
|
988
|
+
// http://www.w3.org/TR/REC-xml-names/#defaulting
|
|
989
|
+
for (var i = 0, l = parser.attribList.length; i < l; i++) {
|
|
990
|
+
var nv = parser.attribList[i]
|
|
991
|
+
var name = nv[0]
|
|
992
|
+
var value = nv[1]
|
|
993
|
+
var qualName = qname(name, true)
|
|
994
|
+
var prefix = qualName.prefix
|
|
995
|
+
var local = qualName.local
|
|
996
|
+
var uri = prefix === '' ? '' : tag.ns[prefix] || ''
|
|
997
|
+
var a = {
|
|
998
|
+
name: name,
|
|
999
|
+
value: value,
|
|
1000
|
+
prefix: prefix,
|
|
1001
|
+
local: local,
|
|
1002
|
+
uri: uri,
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
// if there's any attributes with an undefined namespace,
|
|
1006
|
+
// then fail on them now.
|
|
1007
|
+
if (prefix && prefix !== 'xmlns' && !uri) {
|
|
1008
|
+
strictFail(
|
|
1009
|
+
parser,
|
|
1010
|
+
'Unbound namespace prefix: ' + JSON.stringify(prefix)
|
|
1011
|
+
)
|
|
1012
|
+
a.uri = prefix
|
|
1013
|
+
}
|
|
1014
|
+
parser.tag.attributes[name] = a
|
|
1015
|
+
emitNode(parser, 'onattribute', a)
|
|
1016
|
+
}
|
|
1017
|
+
parser.attribList.length = 0
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
parser.tag.isSelfClosing = !!selfClosing
|
|
1021
|
+
|
|
1022
|
+
// process the tag
|
|
1023
|
+
parser.sawRoot = true
|
|
1024
|
+
parser.tags.push(parser.tag)
|
|
1025
|
+
emitNode(parser, 'onopentag', parser.tag)
|
|
1026
|
+
if (!selfClosing) {
|
|
1027
|
+
// special case for <script> in non-strict mode.
|
|
1028
|
+
if (!parser.noscript && parser.tagName.toLowerCase() === 'script') {
|
|
1029
|
+
parser.state = S.SCRIPT
|
|
1030
|
+
} else {
|
|
1031
|
+
parser.state = S.TEXT
|
|
1032
|
+
}
|
|
1033
|
+
parser.tag = null
|
|
1034
|
+
parser.tagName = ''
|
|
1035
|
+
}
|
|
1036
|
+
parser.attribName = parser.attribValue = ''
|
|
1037
|
+
parser.attribList.length = 0
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
function closeTag(parser) {
|
|
1041
|
+
if (!parser.tagName) {
|
|
1042
|
+
strictFail(parser, 'Weird empty close tag.')
|
|
1043
|
+
parser.textNode += '</>'
|
|
1044
|
+
parser.state = S.TEXT
|
|
1045
|
+
return
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
if (parser.script) {
|
|
1049
|
+
if (parser.tagName !== 'script') {
|
|
1050
|
+
parser.script += '</' + parser.tagName + '>'
|
|
1051
|
+
parser.tagName = ''
|
|
1052
|
+
parser.state = S.SCRIPT
|
|
1053
|
+
return
|
|
1054
|
+
}
|
|
1055
|
+
emitNode(parser, 'onscript', parser.script)
|
|
1056
|
+
parser.script = ''
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
// first make sure that the closing tag actually exists.
|
|
1060
|
+
// <a><b></c></b></a> will close everything, otherwise.
|
|
1061
|
+
var t = parser.tags.length
|
|
1062
|
+
var tagName = parser.tagName
|
|
1063
|
+
if (!parser.strict) {
|
|
1064
|
+
tagName = tagName[parser.looseCase]()
|
|
1065
|
+
}
|
|
1066
|
+
var closeTo = tagName
|
|
1067
|
+
while (t--) {
|
|
1068
|
+
var close = parser.tags[t]
|
|
1069
|
+
if (close.name !== closeTo) {
|
|
1070
|
+
// fail the first time in strict mode
|
|
1071
|
+
strictFail(parser, 'Unexpected close tag')
|
|
1072
|
+
} else {
|
|
1073
|
+
break
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
// didn't find it. we already failed for strict, so just abort.
|
|
1078
|
+
if (t < 0) {
|
|
1079
|
+
strictFail(parser, 'Unmatched closing tag: ' + parser.tagName)
|
|
1080
|
+
parser.textNode += '</' + parser.tagName + '>'
|
|
1081
|
+
parser.state = S.TEXT
|
|
1082
|
+
return
|
|
1083
|
+
}
|
|
1084
|
+
parser.tagName = tagName
|
|
1085
|
+
var s = parser.tags.length
|
|
1086
|
+
while (s-- > t) {
|
|
1087
|
+
var tag = (parser.tag = parser.tags.pop())
|
|
1088
|
+
parser.tagName = parser.tag.name
|
|
1089
|
+
emitNode(parser, 'onclosetag', parser.tagName)
|
|
1090
|
+
|
|
1091
|
+
var x = {}
|
|
1092
|
+
for (var i in tag.ns) {
|
|
1093
|
+
x[i] = tag.ns[i]
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
var parent = parser.tags[parser.tags.length - 1] || parser
|
|
1097
|
+
if (parser.opt.xmlns && tag.ns !== parent.ns) {
|
|
1098
|
+
// remove namespace bindings introduced by tag
|
|
1099
|
+
Object.keys(tag.ns).forEach(function (p) {
|
|
1100
|
+
var n = tag.ns[p]
|
|
1101
|
+
emitNode(parser, 'onclosenamespace', { prefix: p, uri: n })
|
|
1102
|
+
})
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
if (t === 0) parser.closedRoot = true
|
|
1106
|
+
parser.tagName = parser.attribValue = parser.attribName = ''
|
|
1107
|
+
parser.attribList.length = 0
|
|
1108
|
+
parser.state = S.TEXT
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
function parseEntity(parser) {
|
|
1112
|
+
var entity = parser.entity
|
|
1113
|
+
var entityLC = entity.toLowerCase()
|
|
1114
|
+
var num
|
|
1115
|
+
var numStr = ''
|
|
1116
|
+
|
|
1117
|
+
if (parser.ENTITIES[entity]) {
|
|
1118
|
+
return parser.ENTITIES[entity]
|
|
1119
|
+
}
|
|
1120
|
+
if (parser.ENTITIES[entityLC]) {
|
|
1121
|
+
return parser.ENTITIES[entityLC]
|
|
1122
|
+
}
|
|
1123
|
+
entity = entityLC
|
|
1124
|
+
if (entity.charAt(0) === '#') {
|
|
1125
|
+
if (entity.charAt(1) === 'x') {
|
|
1126
|
+
entity = entity.slice(2)
|
|
1127
|
+
num = parseInt(entity, 16)
|
|
1128
|
+
numStr = num.toString(16)
|
|
1129
|
+
} else {
|
|
1130
|
+
entity = entity.slice(1)
|
|
1131
|
+
num = parseInt(entity, 10)
|
|
1132
|
+
numStr = num.toString(10)
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
entity = entity.replace(/^0+/, '')
|
|
1136
|
+
if (
|
|
1137
|
+
isNaN(num) ||
|
|
1138
|
+
numStr.toLowerCase() !== entity ||
|
|
1139
|
+
num < 0 ||
|
|
1140
|
+
num > 0x10ffff
|
|
1141
|
+
) {
|
|
1142
|
+
strictFail(parser, 'Invalid character entity')
|
|
1143
|
+
return '&' + parser.entity + ';'
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
return String.fromCodePoint(num)
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
function beginWhiteSpace(parser, c) {
|
|
1150
|
+
if (c === '<') {
|
|
1151
|
+
parser.state = S.OPEN_WAKA
|
|
1152
|
+
parser.startTagPosition = parser.position
|
|
1153
|
+
} else if (!isWhitespace(c)) {
|
|
1154
|
+
// have to process this as a text node.
|
|
1155
|
+
// weird, but happens.
|
|
1156
|
+
strictFail(parser, 'Non-whitespace before first tag.')
|
|
1157
|
+
parser.textNode = c
|
|
1158
|
+
parser.state = S.TEXT
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
function charAt(chunk, i) {
|
|
1163
|
+
var result = ''
|
|
1164
|
+
if (i < chunk.length) {
|
|
1165
|
+
result = chunk.charAt(i)
|
|
1166
|
+
}
|
|
1167
|
+
return result
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
function write(chunk) {
|
|
1171
|
+
var parser = this
|
|
1172
|
+
if (this.error) {
|
|
1173
|
+
throw this.error
|
|
1174
|
+
}
|
|
1175
|
+
if (parser.closed) {
|
|
1176
|
+
return error(
|
|
1177
|
+
parser,
|
|
1178
|
+
'Cannot write after close. Assign an onready handler.'
|
|
1179
|
+
)
|
|
1180
|
+
}
|
|
1181
|
+
if (chunk === null) {
|
|
1182
|
+
return end(parser)
|
|
1183
|
+
}
|
|
1184
|
+
if (typeof chunk === 'object') {
|
|
1185
|
+
chunk = chunk.toString()
|
|
1186
|
+
}
|
|
1187
|
+
var i = 0
|
|
1188
|
+
var c = ''
|
|
1189
|
+
while (true) {
|
|
1190
|
+
c = charAt(chunk, i++)
|
|
1191
|
+
parser.c = c
|
|
1192
|
+
|
|
1193
|
+
if (!c) {
|
|
1194
|
+
break
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
if (parser.trackPosition) {
|
|
1198
|
+
parser.position++
|
|
1199
|
+
if (c === '\n') {
|
|
1200
|
+
parser.line++
|
|
1201
|
+
parser.column = 0
|
|
1202
|
+
} else {
|
|
1203
|
+
parser.column++
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
switch (parser.state) {
|
|
1208
|
+
case S.BEGIN:
|
|
1209
|
+
parser.state = S.BEGIN_WHITESPACE
|
|
1210
|
+
if (c === '\uFEFF') {
|
|
1211
|
+
continue
|
|
1212
|
+
}
|
|
1213
|
+
beginWhiteSpace(parser, c)
|
|
1214
|
+
continue
|
|
1215
|
+
|
|
1216
|
+
case S.BEGIN_WHITESPACE:
|
|
1217
|
+
beginWhiteSpace(parser, c)
|
|
1218
|
+
continue
|
|
1219
|
+
|
|
1220
|
+
case S.TEXT:
|
|
1221
|
+
if (parser.sawRoot && !parser.closedRoot) {
|
|
1222
|
+
var starti = i - 1
|
|
1223
|
+
while (c && c !== '<' && c !== '&') {
|
|
1224
|
+
c = charAt(chunk, i++)
|
|
1225
|
+
if (c && parser.trackPosition) {
|
|
1226
|
+
parser.position++
|
|
1227
|
+
if (c === '\n') {
|
|
1228
|
+
parser.line++
|
|
1229
|
+
parser.column = 0
|
|
1230
|
+
} else {
|
|
1231
|
+
parser.column++
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
parser.textNode += chunk.substring(starti, i - 1)
|
|
1236
|
+
}
|
|
1237
|
+
if (
|
|
1238
|
+
c === '<' &&
|
|
1239
|
+
!(parser.sawRoot && parser.closedRoot && !parser.strict)
|
|
1240
|
+
) {
|
|
1241
|
+
parser.state = S.OPEN_WAKA
|
|
1242
|
+
parser.startTagPosition = parser.position
|
|
1243
|
+
} else {
|
|
1244
|
+
if (
|
|
1245
|
+
!isWhitespace(c) &&
|
|
1246
|
+
(!parser.sawRoot || parser.closedRoot)
|
|
1247
|
+
) {
|
|
1248
|
+
strictFail(parser, 'Text data outside of root node.')
|
|
1249
|
+
}
|
|
1250
|
+
if (c === '&') {
|
|
1251
|
+
parser.state = S.TEXT_ENTITY
|
|
1252
|
+
} else {
|
|
1253
|
+
parser.textNode += c
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
continue
|
|
1257
|
+
|
|
1258
|
+
case S.SCRIPT:
|
|
1259
|
+
// only non-strict
|
|
1260
|
+
if (c === '<') {
|
|
1261
|
+
parser.state = S.SCRIPT_ENDING
|
|
1262
|
+
} else {
|
|
1263
|
+
parser.script += c
|
|
1264
|
+
}
|
|
1265
|
+
continue
|
|
1266
|
+
|
|
1267
|
+
case S.SCRIPT_ENDING:
|
|
1268
|
+
if (c === '/') {
|
|
1269
|
+
parser.state = S.CLOSE_TAG
|
|
1270
|
+
} else {
|
|
1271
|
+
parser.script += '<' + c
|
|
1272
|
+
parser.state = S.SCRIPT
|
|
1273
|
+
}
|
|
1274
|
+
continue
|
|
1275
|
+
|
|
1276
|
+
case S.OPEN_WAKA:
|
|
1277
|
+
// either a /, ?, !, or text is coming next.
|
|
1278
|
+
if (c === '!') {
|
|
1279
|
+
parser.state = S.SGML_DECL
|
|
1280
|
+
parser.sgmlDecl = ''
|
|
1281
|
+
} else if (isWhitespace(c)) {
|
|
1282
|
+
// wait for it...
|
|
1283
|
+
} else if (isMatch(nameStart, c)) {
|
|
1284
|
+
parser.state = S.OPEN_TAG
|
|
1285
|
+
parser.tagName = c
|
|
1286
|
+
} else if (c === '/') {
|
|
1287
|
+
parser.state = S.CLOSE_TAG
|
|
1288
|
+
parser.tagName = ''
|
|
1289
|
+
} else if (c === '?') {
|
|
1290
|
+
parser.state = S.PROC_INST
|
|
1291
|
+
parser.procInstName = parser.procInstBody = ''
|
|
1292
|
+
} else {
|
|
1293
|
+
strictFail(parser, 'Unencoded <')
|
|
1294
|
+
// if there was some whitespace, then add that in.
|
|
1295
|
+
if (parser.startTagPosition + 1 < parser.position) {
|
|
1296
|
+
var pad = parser.position - parser.startTagPosition
|
|
1297
|
+
c = new Array(pad).join(' ') + c
|
|
1298
|
+
}
|
|
1299
|
+
parser.textNode += '<' + c
|
|
1300
|
+
parser.state = S.TEXT
|
|
1301
|
+
}
|
|
1302
|
+
continue
|
|
1303
|
+
|
|
1304
|
+
case S.SGML_DECL:
|
|
1305
|
+
if (parser.sgmlDecl + c === '--') {
|
|
1306
|
+
parser.state = S.COMMENT
|
|
1307
|
+
parser.comment = ''
|
|
1308
|
+
parser.sgmlDecl = ''
|
|
1309
|
+
continue
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
if (
|
|
1313
|
+
parser.doctype &&
|
|
1314
|
+
parser.doctype !== true &&
|
|
1315
|
+
parser.sgmlDecl
|
|
1316
|
+
) {
|
|
1317
|
+
parser.state = S.DOCTYPE_DTD
|
|
1318
|
+
parser.doctype += '<!' + parser.sgmlDecl + c
|
|
1319
|
+
parser.sgmlDecl = ''
|
|
1320
|
+
} else if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
|
|
1321
|
+
emitNode(parser, 'onopencdata')
|
|
1322
|
+
parser.state = S.CDATA
|
|
1323
|
+
parser.sgmlDecl = ''
|
|
1324
|
+
parser.cdata = ''
|
|
1325
|
+
} else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
|
|
1326
|
+
parser.state = S.DOCTYPE
|
|
1327
|
+
if (parser.doctype || parser.sawRoot) {
|
|
1328
|
+
strictFail(
|
|
1329
|
+
parser,
|
|
1330
|
+
'Inappropriately located doctype declaration'
|
|
1331
|
+
)
|
|
1332
|
+
}
|
|
1333
|
+
parser.doctype = ''
|
|
1334
|
+
parser.sgmlDecl = ''
|
|
1335
|
+
} else if (c === '>') {
|
|
1336
|
+
emitNode(parser, 'onsgmldeclaration', parser.sgmlDecl)
|
|
1337
|
+
parser.sgmlDecl = ''
|
|
1338
|
+
parser.state = S.TEXT
|
|
1339
|
+
} else if (isQuote(c)) {
|
|
1340
|
+
parser.state = S.SGML_DECL_QUOTED
|
|
1341
|
+
parser.sgmlDecl += c
|
|
1342
|
+
} else {
|
|
1343
|
+
parser.sgmlDecl += c
|
|
1344
|
+
}
|
|
1345
|
+
continue
|
|
1346
|
+
|
|
1347
|
+
case S.SGML_DECL_QUOTED:
|
|
1348
|
+
if (c === parser.q) {
|
|
1349
|
+
parser.state = S.SGML_DECL
|
|
1350
|
+
parser.q = ''
|
|
1351
|
+
}
|
|
1352
|
+
parser.sgmlDecl += c
|
|
1353
|
+
continue
|
|
1354
|
+
|
|
1355
|
+
case S.DOCTYPE:
|
|
1356
|
+
if (c === '>') {
|
|
1357
|
+
parser.state = S.TEXT
|
|
1358
|
+
emitNode(parser, 'ondoctype', parser.doctype)
|
|
1359
|
+
parser.doctype = true // just remember that we saw it.
|
|
1360
|
+
} else {
|
|
1361
|
+
parser.doctype += c
|
|
1362
|
+
if (c === '[') {
|
|
1363
|
+
parser.state = S.DOCTYPE_DTD
|
|
1364
|
+
} else if (isQuote(c)) {
|
|
1365
|
+
parser.state = S.DOCTYPE_QUOTED
|
|
1366
|
+
parser.q = c
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
continue
|
|
1370
|
+
|
|
1371
|
+
case S.DOCTYPE_QUOTED:
|
|
1372
|
+
parser.doctype += c
|
|
1373
|
+
if (c === parser.q) {
|
|
1374
|
+
parser.q = ''
|
|
1375
|
+
parser.state = S.DOCTYPE
|
|
1376
|
+
}
|
|
1377
|
+
continue
|
|
1378
|
+
|
|
1379
|
+
case S.DOCTYPE_DTD:
|
|
1380
|
+
if (c === ']') {
|
|
1381
|
+
parser.doctype += c
|
|
1382
|
+
parser.state = S.DOCTYPE
|
|
1383
|
+
} else if (c === '<') {
|
|
1384
|
+
parser.state = S.OPEN_WAKA
|
|
1385
|
+
parser.startTagPosition = parser.position
|
|
1386
|
+
} else if (isQuote(c)) {
|
|
1387
|
+
parser.doctype += c
|
|
1388
|
+
parser.state = S.DOCTYPE_DTD_QUOTED
|
|
1389
|
+
parser.q = c
|
|
1390
|
+
} else {
|
|
1391
|
+
parser.doctype += c
|
|
1392
|
+
}
|
|
1393
|
+
continue
|
|
1394
|
+
|
|
1395
|
+
case S.DOCTYPE_DTD_QUOTED:
|
|
1396
|
+
parser.doctype += c
|
|
1397
|
+
if (c === parser.q) {
|
|
1398
|
+
parser.state = S.DOCTYPE_DTD
|
|
1399
|
+
parser.q = ''
|
|
1400
|
+
}
|
|
1401
|
+
continue
|
|
1402
|
+
|
|
1403
|
+
case S.COMMENT:
|
|
1404
|
+
if (c === '-') {
|
|
1405
|
+
parser.state = S.COMMENT_ENDING
|
|
1406
|
+
} else {
|
|
1407
|
+
parser.comment += c
|
|
1408
|
+
}
|
|
1409
|
+
continue
|
|
1410
|
+
|
|
1411
|
+
case S.COMMENT_ENDING:
|
|
1412
|
+
if (c === '-') {
|
|
1413
|
+
parser.state = S.COMMENT_ENDED
|
|
1414
|
+
parser.comment = textopts(parser.opt, parser.comment)
|
|
1415
|
+
if (parser.comment) {
|
|
1416
|
+
emitNode(parser, 'oncomment', parser.comment)
|
|
1417
|
+
}
|
|
1418
|
+
parser.comment = ''
|
|
1419
|
+
} else {
|
|
1420
|
+
parser.comment += '-' + c
|
|
1421
|
+
parser.state = S.COMMENT
|
|
1422
|
+
}
|
|
1423
|
+
continue
|
|
1424
|
+
|
|
1425
|
+
case S.COMMENT_ENDED:
|
|
1426
|
+
if (c !== '>') {
|
|
1427
|
+
strictFail(parser, 'Malformed comment')
|
|
1428
|
+
// allow <!-- blah -- bloo --> in non-strict mode,
|
|
1429
|
+
// which is a comment of " blah -- bloo "
|
|
1430
|
+
parser.comment += '--' + c
|
|
1431
|
+
parser.state = S.COMMENT
|
|
1432
|
+
} else if (parser.doctype && parser.doctype !== true) {
|
|
1433
|
+
parser.state = S.DOCTYPE_DTD
|
|
1434
|
+
} else {
|
|
1435
|
+
parser.state = S.TEXT
|
|
1436
|
+
}
|
|
1437
|
+
continue
|
|
1438
|
+
|
|
1439
|
+
case S.CDATA:
|
|
1440
|
+
var starti = i - 1
|
|
1441
|
+
while (c && c !== ']') {
|
|
1442
|
+
c = charAt(chunk, i++)
|
|
1443
|
+
if (c && parser.trackPosition) {
|
|
1444
|
+
parser.position++
|
|
1445
|
+
if (c === '\n') {
|
|
1446
|
+
parser.line++
|
|
1447
|
+
parser.column = 0
|
|
1448
|
+
} else {
|
|
1449
|
+
parser.column++
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
parser.cdata += chunk.substring(starti, i - 1)
|
|
1454
|
+
if (c === ']') {
|
|
1455
|
+
parser.state = S.CDATA_ENDING
|
|
1456
|
+
}
|
|
1457
|
+
continue
|
|
1458
|
+
|
|
1459
|
+
case S.CDATA_ENDING:
|
|
1460
|
+
if (c === ']') {
|
|
1461
|
+
parser.state = S.CDATA_ENDING_2
|
|
1462
|
+
} else {
|
|
1463
|
+
parser.cdata += ']' + c
|
|
1464
|
+
parser.state = S.CDATA
|
|
1465
|
+
}
|
|
1466
|
+
continue
|
|
1467
|
+
|
|
1468
|
+
case S.CDATA_ENDING_2:
|
|
1469
|
+
if (c === '>') {
|
|
1470
|
+
if (parser.cdata) {
|
|
1471
|
+
emitNode(parser, 'oncdata', parser.cdata)
|
|
1472
|
+
}
|
|
1473
|
+
emitNode(parser, 'onclosecdata')
|
|
1474
|
+
parser.cdata = ''
|
|
1475
|
+
parser.state = S.TEXT
|
|
1476
|
+
} else if (c === ']') {
|
|
1477
|
+
parser.cdata += ']'
|
|
1478
|
+
} else {
|
|
1479
|
+
parser.cdata += ']]' + c
|
|
1480
|
+
parser.state = S.CDATA
|
|
1481
|
+
}
|
|
1482
|
+
continue
|
|
1483
|
+
|
|
1484
|
+
case S.PROC_INST:
|
|
1485
|
+
if (c === '?') {
|
|
1486
|
+
parser.state = S.PROC_INST_ENDING
|
|
1487
|
+
} else if (isWhitespace(c)) {
|
|
1488
|
+
parser.state = S.PROC_INST_BODY
|
|
1489
|
+
} else {
|
|
1490
|
+
parser.procInstName += c
|
|
1491
|
+
}
|
|
1492
|
+
continue
|
|
1493
|
+
|
|
1494
|
+
case S.PROC_INST_BODY:
|
|
1495
|
+
if (!parser.procInstBody && isWhitespace(c)) {
|
|
1496
|
+
continue
|
|
1497
|
+
} else if (c === '?') {
|
|
1498
|
+
parser.state = S.PROC_INST_ENDING
|
|
1499
|
+
} else {
|
|
1500
|
+
parser.procInstBody += c
|
|
1501
|
+
}
|
|
1502
|
+
continue
|
|
1503
|
+
|
|
1504
|
+
case S.PROC_INST_ENDING:
|
|
1505
|
+
if (c === '>') {
|
|
1506
|
+
const procInstEndData = {
|
|
1507
|
+
name: parser.procInstName,
|
|
1508
|
+
body: parser.procInstBody,
|
|
1509
|
+
}
|
|
1510
|
+
validateXmlDeclarationEncoding(parser, procInstEndData)
|
|
1511
|
+
emitNode(parser, 'onprocessinginstruction', procInstEndData)
|
|
1512
|
+
parser.procInstName = parser.procInstBody = ''
|
|
1513
|
+
parser.state = S.TEXT
|
|
1514
|
+
} else {
|
|
1515
|
+
parser.procInstBody += '?' + c
|
|
1516
|
+
parser.state = S.PROC_INST_BODY
|
|
1517
|
+
}
|
|
1518
|
+
continue
|
|
1519
|
+
|
|
1520
|
+
case S.OPEN_TAG:
|
|
1521
|
+
if (isMatch(nameBody, c)) {
|
|
1522
|
+
parser.tagName += c
|
|
1523
|
+
} else {
|
|
1524
|
+
newTag(parser)
|
|
1525
|
+
if (c === '>') {
|
|
1526
|
+
openTag(parser)
|
|
1527
|
+
} else if (c === '/') {
|
|
1528
|
+
parser.state = S.OPEN_TAG_SLASH
|
|
1529
|
+
} else {
|
|
1530
|
+
if (!isWhitespace(c)) {
|
|
1531
|
+
strictFail(parser, 'Invalid character in tag name')
|
|
1532
|
+
}
|
|
1533
|
+
parser.state = S.ATTRIB
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
continue
|
|
1537
|
+
|
|
1538
|
+
case S.OPEN_TAG_SLASH:
|
|
1539
|
+
if (c === '>') {
|
|
1540
|
+
openTag(parser, true)
|
|
1541
|
+
closeTag(parser)
|
|
1542
|
+
} else {
|
|
1543
|
+
strictFail(
|
|
1544
|
+
parser,
|
|
1545
|
+
'Forward-slash in opening tag not followed by >'
|
|
1546
|
+
)
|
|
1547
|
+
parser.state = S.ATTRIB
|
|
1548
|
+
}
|
|
1549
|
+
continue
|
|
1550
|
+
|
|
1551
|
+
case S.ATTRIB:
|
|
1552
|
+
// haven't read the attribute name yet.
|
|
1553
|
+
if (isWhitespace(c)) {
|
|
1554
|
+
continue
|
|
1555
|
+
} else if (c === '>') {
|
|
1556
|
+
openTag(parser)
|
|
1557
|
+
} else if (c === '/') {
|
|
1558
|
+
parser.state = S.OPEN_TAG_SLASH
|
|
1559
|
+
} else if (isMatch(nameStart, c)) {
|
|
1560
|
+
parser.attribName = c
|
|
1561
|
+
parser.attribValue = ''
|
|
1562
|
+
parser.state = S.ATTRIB_NAME
|
|
1563
|
+
} else {
|
|
1564
|
+
strictFail(parser, 'Invalid attribute name')
|
|
1565
|
+
}
|
|
1566
|
+
continue
|
|
1567
|
+
|
|
1568
|
+
case S.ATTRIB_NAME:
|
|
1569
|
+
if (c === '=') {
|
|
1570
|
+
parser.state = S.ATTRIB_VALUE
|
|
1571
|
+
} else if (c === '>') {
|
|
1572
|
+
strictFail(parser, 'Attribute without value')
|
|
1573
|
+
parser.attribValue = parser.attribName
|
|
1574
|
+
attrib(parser)
|
|
1575
|
+
openTag(parser)
|
|
1576
|
+
} else if (isWhitespace(c)) {
|
|
1577
|
+
parser.state = S.ATTRIB_NAME_SAW_WHITE
|
|
1578
|
+
} else if (isMatch(nameBody, c)) {
|
|
1579
|
+
parser.attribName += c
|
|
1580
|
+
} else {
|
|
1581
|
+
strictFail(parser, 'Invalid attribute name')
|
|
1582
|
+
}
|
|
1583
|
+
continue
|
|
1584
|
+
|
|
1585
|
+
case S.ATTRIB_NAME_SAW_WHITE:
|
|
1586
|
+
if (c === '=') {
|
|
1587
|
+
parser.state = S.ATTRIB_VALUE
|
|
1588
|
+
} else if (isWhitespace(c)) {
|
|
1589
|
+
continue
|
|
1590
|
+
} else {
|
|
1591
|
+
strictFail(parser, 'Attribute without value')
|
|
1592
|
+
parser.tag.attributes[parser.attribName] = ''
|
|
1593
|
+
parser.attribValue = ''
|
|
1594
|
+
emitNode(parser, 'onattribute', {
|
|
1595
|
+
name: parser.attribName,
|
|
1596
|
+
value: '',
|
|
1597
|
+
})
|
|
1598
|
+
parser.attribName = ''
|
|
1599
|
+
if (c === '>') {
|
|
1600
|
+
openTag(parser)
|
|
1601
|
+
} else if (isMatch(nameStart, c)) {
|
|
1602
|
+
parser.attribName = c
|
|
1603
|
+
parser.state = S.ATTRIB_NAME
|
|
1604
|
+
} else {
|
|
1605
|
+
strictFail(parser, 'Invalid attribute name')
|
|
1606
|
+
parser.state = S.ATTRIB
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
continue
|
|
1610
|
+
|
|
1611
|
+
case S.ATTRIB_VALUE:
|
|
1612
|
+
if (isWhitespace(c)) {
|
|
1613
|
+
continue
|
|
1614
|
+
} else if (isQuote(c)) {
|
|
1615
|
+
parser.q = c
|
|
1616
|
+
parser.state = S.ATTRIB_VALUE_QUOTED
|
|
1617
|
+
} else {
|
|
1618
|
+
if (!parser.opt.unquotedAttributeValues) {
|
|
1619
|
+
error(parser, 'Unquoted attribute value')
|
|
1620
|
+
}
|
|
1621
|
+
parser.state = S.ATTRIB_VALUE_UNQUOTED
|
|
1622
|
+
parser.attribValue = c
|
|
1623
|
+
}
|
|
1624
|
+
continue
|
|
1625
|
+
|
|
1626
|
+
case S.ATTRIB_VALUE_QUOTED:
|
|
1627
|
+
if (c !== parser.q) {
|
|
1628
|
+
if (c === '&') {
|
|
1629
|
+
parser.state = S.ATTRIB_VALUE_ENTITY_Q
|
|
1630
|
+
} else {
|
|
1631
|
+
parser.attribValue += c
|
|
1632
|
+
}
|
|
1633
|
+
continue
|
|
1634
|
+
}
|
|
1635
|
+
attrib(parser)
|
|
1636
|
+
parser.q = ''
|
|
1637
|
+
parser.state = S.ATTRIB_VALUE_CLOSED
|
|
1638
|
+
continue
|
|
1639
|
+
|
|
1640
|
+
case S.ATTRIB_VALUE_CLOSED:
|
|
1641
|
+
if (isWhitespace(c)) {
|
|
1642
|
+
parser.state = S.ATTRIB
|
|
1643
|
+
} else if (c === '>') {
|
|
1644
|
+
openTag(parser)
|
|
1645
|
+
} else if (c === '/') {
|
|
1646
|
+
parser.state = S.OPEN_TAG_SLASH
|
|
1647
|
+
} else if (isMatch(nameStart, c)) {
|
|
1648
|
+
strictFail(parser, 'No whitespace between attributes')
|
|
1649
|
+
parser.attribName = c
|
|
1650
|
+
parser.attribValue = ''
|
|
1651
|
+
parser.state = S.ATTRIB_NAME
|
|
1652
|
+
} else {
|
|
1653
|
+
strictFail(parser, 'Invalid attribute name')
|
|
1654
|
+
}
|
|
1655
|
+
continue
|
|
1656
|
+
|
|
1657
|
+
case S.ATTRIB_VALUE_UNQUOTED:
|
|
1658
|
+
if (!isAttribEnd(c)) {
|
|
1659
|
+
if (c === '&') {
|
|
1660
|
+
parser.state = S.ATTRIB_VALUE_ENTITY_U
|
|
1661
|
+
} else {
|
|
1662
|
+
parser.attribValue += c
|
|
1663
|
+
}
|
|
1664
|
+
continue
|
|
1665
|
+
}
|
|
1666
|
+
attrib(parser)
|
|
1667
|
+
if (c === '>') {
|
|
1668
|
+
openTag(parser)
|
|
1669
|
+
} else {
|
|
1670
|
+
parser.state = S.ATTRIB
|
|
1671
|
+
}
|
|
1672
|
+
continue
|
|
1673
|
+
|
|
1674
|
+
case S.CLOSE_TAG:
|
|
1675
|
+
if (!parser.tagName) {
|
|
1676
|
+
if (isWhitespace(c)) {
|
|
1677
|
+
continue
|
|
1678
|
+
} else if (notMatch(nameStart, c)) {
|
|
1679
|
+
if (parser.script) {
|
|
1680
|
+
parser.script += '</' + c
|
|
1681
|
+
parser.state = S.SCRIPT
|
|
1682
|
+
} else {
|
|
1683
|
+
strictFail(parser, 'Invalid tagname in closing tag.')
|
|
1684
|
+
}
|
|
1685
|
+
} else {
|
|
1686
|
+
parser.tagName = c
|
|
1687
|
+
}
|
|
1688
|
+
} else if (c === '>') {
|
|
1689
|
+
closeTag(parser)
|
|
1690
|
+
} else if (isMatch(nameBody, c)) {
|
|
1691
|
+
parser.tagName += c
|
|
1692
|
+
} else if (parser.script) {
|
|
1693
|
+
parser.script += '</' + parser.tagName + c
|
|
1694
|
+
parser.tagName = ''
|
|
1695
|
+
parser.state = S.SCRIPT
|
|
1696
|
+
} else {
|
|
1697
|
+
if (!isWhitespace(c)) {
|
|
1698
|
+
strictFail(parser, 'Invalid tagname in closing tag')
|
|
1699
|
+
}
|
|
1700
|
+
parser.state = S.CLOSE_TAG_SAW_WHITE
|
|
1701
|
+
}
|
|
1702
|
+
continue
|
|
1703
|
+
|
|
1704
|
+
case S.CLOSE_TAG_SAW_WHITE:
|
|
1705
|
+
if (isWhitespace(c)) {
|
|
1706
|
+
continue
|
|
1707
|
+
}
|
|
1708
|
+
if (c === '>') {
|
|
1709
|
+
closeTag(parser)
|
|
1710
|
+
} else {
|
|
1711
|
+
strictFail(parser, 'Invalid characters in closing tag')
|
|
1712
|
+
}
|
|
1713
|
+
continue
|
|
1714
|
+
|
|
1715
|
+
case S.TEXT_ENTITY:
|
|
1716
|
+
case S.ATTRIB_VALUE_ENTITY_Q:
|
|
1717
|
+
case S.ATTRIB_VALUE_ENTITY_U:
|
|
1718
|
+
var returnState
|
|
1719
|
+
var buffer
|
|
1720
|
+
switch (parser.state) {
|
|
1721
|
+
case S.TEXT_ENTITY:
|
|
1722
|
+
returnState = S.TEXT
|
|
1723
|
+
buffer = 'textNode'
|
|
1724
|
+
break
|
|
1725
|
+
|
|
1726
|
+
case S.ATTRIB_VALUE_ENTITY_Q:
|
|
1727
|
+
returnState = S.ATTRIB_VALUE_QUOTED
|
|
1728
|
+
buffer = 'attribValue'
|
|
1729
|
+
break
|
|
1730
|
+
|
|
1731
|
+
case S.ATTRIB_VALUE_ENTITY_U:
|
|
1732
|
+
returnState = S.ATTRIB_VALUE_UNQUOTED
|
|
1733
|
+
buffer = 'attribValue'
|
|
1734
|
+
break
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
if (c === ';') {
|
|
1738
|
+
var parsedEntity = parseEntity(parser)
|
|
1739
|
+
if (
|
|
1740
|
+
parser.opt.unparsedEntities &&
|
|
1741
|
+
!Object.values(sax.XML_ENTITIES).includes(parsedEntity)
|
|
1742
|
+
) {
|
|
1743
|
+
if ((parser.entityCount += 1) > parser.opt.maxEntityCount) {
|
|
1744
|
+
error(
|
|
1745
|
+
parser,
|
|
1746
|
+
'Parsed entity count exceeds max entity count'
|
|
1747
|
+
)
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
if ((parser.entityDepth += 1) > parser.opt.maxEntityDepth) {
|
|
1751
|
+
error(
|
|
1752
|
+
parser,
|
|
1753
|
+
'Parsed entity depth exceeds max entity depth'
|
|
1754
|
+
)
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
parser.entity = ''
|
|
1758
|
+
parser.state = returnState
|
|
1759
|
+
parser.write(parsedEntity)
|
|
1760
|
+
parser.entityDepth -= 1
|
|
1761
|
+
} else {
|
|
1762
|
+
parser[buffer] += parsedEntity
|
|
1763
|
+
parser.entity = ''
|
|
1764
|
+
parser.state = returnState
|
|
1765
|
+
}
|
|
1766
|
+
} else if (
|
|
1767
|
+
isMatch(parser.entity.length ? entityBody : entityStart, c)
|
|
1768
|
+
) {
|
|
1769
|
+
parser.entity += c
|
|
1770
|
+
} else {
|
|
1771
|
+
strictFail(parser, 'Invalid character in entity name')
|
|
1772
|
+
parser[buffer] += '&' + parser.entity + c
|
|
1773
|
+
parser.entity = ''
|
|
1774
|
+
parser.state = returnState
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
continue
|
|
1778
|
+
|
|
1779
|
+
default: /* istanbul ignore next */ {
|
|
1780
|
+
throw new Error(parser, 'Unknown state: ' + parser.state)
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
} // while
|
|
1784
|
+
|
|
1785
|
+
if (parser.position >= parser.bufferCheckPosition) {
|
|
1786
|
+
checkBufferLength(parser)
|
|
1787
|
+
}
|
|
1788
|
+
return parser
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
|
|
1792
|
+
/* istanbul ignore next */
|
|
1793
|
+
if (!String.fromCodePoint) {
|
|
1794
|
+
;(function () {
|
|
1795
|
+
var stringFromCharCode = String.fromCharCode
|
|
1796
|
+
var floor = Math.floor
|
|
1797
|
+
var fromCodePoint = function () {
|
|
1798
|
+
var MAX_SIZE = 0x4000
|
|
1799
|
+
var codeUnits = []
|
|
1800
|
+
var highSurrogate
|
|
1801
|
+
var lowSurrogate
|
|
1802
|
+
var index = -1
|
|
1803
|
+
var length = arguments.length
|
|
1804
|
+
if (!length) {
|
|
1805
|
+
return ''
|
|
1806
|
+
}
|
|
1807
|
+
var result = ''
|
|
1808
|
+
while (++index < length) {
|
|
1809
|
+
var codePoint = Number(arguments[index])
|
|
1810
|
+
if (
|
|
1811
|
+
!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
|
|
1812
|
+
codePoint < 0 || // not a valid Unicode code point
|
|
1813
|
+
codePoint > 0x10ffff || // not a valid Unicode code point
|
|
1814
|
+
floor(codePoint) !== codePoint // not an integer
|
|
1815
|
+
) {
|
|
1816
|
+
throw RangeError('Invalid code point: ' + codePoint)
|
|
1817
|
+
}
|
|
1818
|
+
if (codePoint <= 0xffff) {
|
|
1819
|
+
// BMP code point
|
|
1820
|
+
codeUnits.push(codePoint)
|
|
1821
|
+
} else {
|
|
1822
|
+
// Astral code point; split in surrogate halves
|
|
1823
|
+
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
|
1824
|
+
codePoint -= 0x10000
|
|
1825
|
+
highSurrogate = (codePoint >> 10) + 0xd800
|
|
1826
|
+
lowSurrogate = (codePoint % 0x400) + 0xdc00
|
|
1827
|
+
codeUnits.push(highSurrogate, lowSurrogate)
|
|
1828
|
+
}
|
|
1829
|
+
if (index + 1 === length || codeUnits.length > MAX_SIZE) {
|
|
1830
|
+
result += stringFromCharCode.apply(null, codeUnits)
|
|
1831
|
+
codeUnits.length = 0
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
return result
|
|
1835
|
+
}
|
|
1836
|
+
/* istanbul ignore next */
|
|
1837
|
+
if (Object.defineProperty) {
|
|
1838
|
+
Object.defineProperty(String, 'fromCodePoint', {
|
|
1839
|
+
value: fromCodePoint,
|
|
1840
|
+
configurable: true,
|
|
1841
|
+
writable: true,
|
|
1842
|
+
})
|
|
1843
|
+
} else {
|
|
1844
|
+
String.fromCodePoint = fromCodePoint
|
|
1845
|
+
}
|
|
1846
|
+
})()
|
|
1847
|
+
}
|
|
1848
|
+
})(typeof exports === 'undefined' ? (this.sax = {}) : exports)
|