@zowe/cli 8.36.1 → 8.37.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/lib/zosfiles/-strings-/en.d.ts +2 -0
- package/lib/zosfiles/-strings-/en.d.ts.map +1 -1
- package/lib/zosfiles/-strings-/en.js +5 -1
- package/lib/zosfiles/-strings-/en.js.map +1 -1
- package/lib/zosfiles/ZosFiles.options.d.ts.map +1 -1
- package/lib/zosfiles/ZosFiles.options.js +3 -1
- package/lib/zosfiles/ZosFiles.options.js.map +1 -1
- package/lib/zosfiles/create/Create.utils.d.ts.map +1 -1
- package/lib/zosfiles/create/Create.utils.js +3 -1
- package/lib/zosfiles/create/Create.utils.js.map +1 -1
- package/lib/zosfiles/create/ussDir/ussDir.handler.d.ts.map +1 -1
- package/lib/zosfiles/create/ussDir/ussDir.handler.js +5 -1
- package/lib/zosfiles/create/ussDir/ussDir.handler.js.map +1 -1
- package/lib/zosfiles/create/ussFile/ussFile.handler.d.ts.map +1 -1
- package/lib/zosfiles/create/ussFile/ussFile.handler.js +5 -1
- package/lib/zosfiles/create/ussFile/ussFile.handler.js.map +1 -1
- package/lib/zosfiles/create/vsam/vsam.handler.d.ts.map +1 -1
- package/lib/zosfiles/create/vsam/vsam.handler.js +3 -1
- package/lib/zosfiles/create/vsam/vsam.handler.js.map +1 -1
- package/lib/zosfiles/create/zfs/zfs.handler.d.ts.map +1 -1
- package/lib/zosfiles/create/zfs/zfs.handler.js +3 -1
- package/lib/zosfiles/create/zfs/zfs.handler.js.map +1 -1
- package/lib/zosfiles/delete/ds/Ds.handler.d.ts.map +1 -1
- package/lib/zosfiles/delete/ds/Ds.handler.js +4 -1
- package/lib/zosfiles/delete/ds/Ds.handler.js.map +1 -1
- package/lib/zosfiles/delete/uss/Uss.handler.d.ts.map +1 -1
- package/lib/zosfiles/delete/uss/Uss.handler.js +5 -1
- package/lib/zosfiles/delete/uss/Uss.handler.js.map +1 -1
- package/lib/zosfiles/delete/vsam/Vsam.handler.d.ts.map +1 -1
- package/lib/zosfiles/delete/vsam/Vsam.handler.js +3 -1
- package/lib/zosfiles/delete/vsam/Vsam.handler.js.map +1 -1
- package/lib/zosfiles/delete/zfs/zfs.handler.d.ts.map +1 -1
- package/lib/zosfiles/delete/zfs/zfs.handler.js +3 -1
- package/lib/zosfiles/delete/zfs/zfs.handler.js.map +1 -1
- package/lib/zosfiles/download/am/AllMembers.handler.d.ts.map +1 -1
- package/lib/zosfiles/download/am/AllMembers.handler.js +3 -1
- package/lib/zosfiles/download/am/AllMembers.handler.js.map +1 -1
- package/lib/zosfiles/download/amm/AllMembersMatching.handler.d.ts.map +1 -1
- package/lib/zosfiles/download/amm/AllMembersMatching.handler.js +2 -0
- package/lib/zosfiles/download/amm/AllMembersMatching.handler.js.map +1 -1
- package/lib/zosfiles/download/ds/Dataset.handler.d.ts.map +1 -1
- package/lib/zosfiles/download/ds/Dataset.handler.js +3 -1
- package/lib/zosfiles/download/ds/Dataset.handler.js.map +1 -1
- package/lib/zosfiles/download/dsm/DataSetMatching.handler.d.ts.map +1 -1
- package/lib/zosfiles/download/dsm/DataSetMatching.handler.js +6 -2
- package/lib/zosfiles/download/dsm/DataSetMatching.handler.js.map +1 -1
- package/lib/zosfiles/download/uss/UssFile.handler.d.ts.map +1 -1
- package/lib/zosfiles/download/uss/UssFile.handler.js +2 -0
- package/lib/zosfiles/download/uss/UssFile.handler.js.map +1 -1
- package/lib/zosfiles/download/ussdir/UssDir.handler.d.ts.map +1 -1
- package/lib/zosfiles/download/ussdir/UssDir.handler.js +6 -2
- package/lib/zosfiles/download/ussdir/UssDir.handler.js.map +1 -1
- package/lib/zosfiles/edit/Edit.utils.d.ts +2 -2
- package/lib/zosfiles/edit/Edit.utils.d.ts.map +1 -1
- package/lib/zosfiles/edit/Edit.utils.js +10 -10
- package/lib/zosfiles/edit/Edit.utils.js.map +1 -1
- package/lib/zosfiles/invoke/amsFile/AmsFile.handler.d.ts.map +1 -1
- package/lib/zosfiles/invoke/amsFile/AmsFile.handler.js +5 -1
- package/lib/zosfiles/invoke/amsFile/AmsFile.handler.js.map +1 -1
- package/lib/zosfiles/invoke/amsStatements/AmsStatements.handler.d.ts.map +1 -1
- package/lib/zosfiles/invoke/amsStatements/AmsStatements.handler.js +5 -1
- package/lib/zosfiles/invoke/amsStatements/AmsStatements.handler.js.map +1 -1
- package/lib/zosfiles/list/alias/Alias.handler.d.ts.map +1 -1
- package/lib/zosfiles/list/alias/Alias.handler.js +3 -1
- package/lib/zosfiles/list/alias/Alias.handler.js.map +1 -1
- package/lib/zosfiles/list/am/AllMembers.handler.d.ts.map +1 -1
- package/lib/zosfiles/list/am/AllMembers.handler.js +3 -1
- package/lib/zosfiles/list/am/AllMembers.handler.js.map +1 -1
- package/lib/zosfiles/list/ds/DataSet.handler.d.ts.map +1 -1
- package/lib/zosfiles/list/ds/DataSet.handler.js +3 -1
- package/lib/zosfiles/list/ds/DataSet.handler.js.map +1 -1
- package/lib/zosfiles/list/fs/Fs.handler.d.ts.map +1 -1
- package/lib/zosfiles/list/fs/Fs.handler.js +6 -2
- package/lib/zosfiles/list/fs/Fs.handler.js.map +1 -1
- package/lib/zosfiles/list/uss/UssFile.handler.d.ts.map +1 -1
- package/lib/zosfiles/list/uss/UssFile.handler.js +3 -1
- package/lib/zosfiles/list/uss/UssFile.handler.js.map +1 -1
- package/lib/zosfiles/mount/fs/fs.handler.d.ts.map +1 -1
- package/lib/zosfiles/mount/fs/fs.handler.js +3 -1
- package/lib/zosfiles/mount/fs/fs.handler.js.map +1 -1
- package/lib/zosfiles/rename/ds/Ds.handler.d.ts.map +1 -1
- package/lib/zosfiles/rename/ds/Ds.handler.js +4 -1
- package/lib/zosfiles/rename/ds/Ds.handler.js.map +1 -1
- package/lib/zosfiles/rename/dsm/Dsm.handler.d.ts.map +1 -1
- package/lib/zosfiles/rename/dsm/Dsm.handler.js +4 -1
- package/lib/zosfiles/rename/dsm/Dsm.handler.js.map +1 -1
- package/lib/zosfiles/search/ds/DataSets.handler.d.ts.map +1 -1
- package/lib/zosfiles/search/ds/DataSets.handler.js +10 -2
- package/lib/zosfiles/search/ds/DataSets.handler.js.map +1 -1
- package/lib/zosfiles/upload/dtp/DirToPds.handler.d.ts.map +1 -1
- package/lib/zosfiles/upload/dtp/DirToPds.handler.js +3 -1
- package/lib/zosfiles/upload/dtp/DirToPds.handler.js.map +1 -1
- package/lib/zosfiles/upload/dtu/DirToUSSDir.handler.d.ts.map +1 -1
- package/lib/zosfiles/upload/dtu/DirToUSSDir.handler.js +3 -1
- package/lib/zosfiles/upload/dtu/DirToUSSDir.handler.js.map +1 -1
- package/lib/zosfiles/upload/ftds/FileToDataSet.handler.d.ts.map +1 -1
- package/lib/zosfiles/upload/ftds/FileToDataSet.handler.js +3 -1
- package/lib/zosfiles/upload/ftds/FileToDataSet.handler.js.map +1 -1
- package/lib/zosfiles/upload/ftu/FileToUSS.handler.d.ts.map +1 -1
- package/lib/zosfiles/upload/ftu/FileToUSS.handler.js +3 -1
- package/lib/zosfiles/upload/ftu/FileToUSS.handler.js.map +1 -1
- package/lib/zosfiles/upload/stds/StdinToDataSet.handler.d.ts.map +1 -1
- package/lib/zosfiles/upload/stds/StdinToDataSet.handler.js +3 -1
- package/lib/zosfiles/upload/stds/StdinToDataSet.handler.js.map +1 -1
- package/lib/zosfiles/view/ds/Dataset.handler.d.ts.map +1 -1
- package/lib/zosfiles/view/ds/Dataset.handler.js +3 -1
- package/lib/zosfiles/view/ds/Dataset.handler.js.map +1 -1
- package/lib/zosfiles/view/uss/USSFile.handler.d.ts.map +1 -1
- package/lib/zosfiles/view/uss/USSFile.handler.js +3 -1
- package/lib/zosfiles/view/uss/USSFile.handler.js.map +1 -1
- package/node_modules/@zowe/core-for-zowe-sdk/lib/rest/ZosmfHeaders.d.ts +14 -0
- package/node_modules/@zowe/core-for-zowe-sdk/lib/rest/ZosmfHeaders.d.ts.map +1 -1
- package/node_modules/@zowe/core-for-zowe-sdk/lib/rest/ZosmfHeaders.js +14 -0
- package/node_modules/@zowe/core-for-zowe-sdk/lib/rest/ZosmfHeaders.js.map +1 -1
- package/node_modules/@zowe/core-for-zowe-sdk/package.json +3 -3
- package/node_modules/@zowe/imperative/lib/config/src/ConfigSchema.d.ts.map +1 -1
- package/node_modules/@zowe/imperative/lib/config/src/ConfigSchema.js +1 -0
- package/node_modules/@zowe/imperative/lib/config/src/ConfigSchema.js.map +1 -1
- package/node_modules/@zowe/imperative/package.json +3 -3
- package/node_modules/@zowe/imperative/web-help/package-lock.json +62 -62
- package/node_modules/@zowe/provisioning-for-zowe-sdk/package.json +4 -4
- package/node_modules/@zowe/secrets-for-zowe-sdk/README.md +70 -0
- package/node_modules/@zowe/secrets-for-zowe-sdk/package.json +1 -1
- package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.darwin-arm64.node +0 -0
- package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.darwin-x64.node +0 -0
- package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.linux-arm-gnueabihf.node +0 -0
- package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.linux-arm64-gnu.node +0 -0
- package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.linux-ia32-gnu.node +0 -0
- package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.linux-x64-gnu.node +0 -0
- package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.win32-arm64-msvc.node +0 -0
- package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.win32-ia32-msvc.node +0 -0
- package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.win32-x64-msvc.node +0 -0
- package/node_modules/@zowe/zos-console-for-zowe-sdk/package.json +4 -4
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/doc/IZosFilesOptions.d.ts +12 -0
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/doc/IZosFilesOptions.d.ts.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/copy/Copy.js +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/copy/Copy.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/create/Create.d.ts.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/create/Create.js +18 -3
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/create/Create.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/delete/Delete.d.ts.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/delete/Delete.js +7 -3
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/delete/Delete.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/download/Download.js +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/download/Download.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/invoke/Invoke.d.ts.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/invoke/Invoke.js +2 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/invoke/Invoke.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/list/List.d.ts.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/list/List.js +6 -5
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/list/List.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/mount/Mount.d.ts.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/mount/Mount.js +6 -0
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/mount/Mount.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/rename/Rename.d.ts.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/rename/Rename.js +2 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/rename/Rename.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/unmount/Unmount.d.ts.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/unmount/Unmount.js +3 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/unmount/Unmount.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/upload/Upload.d.ts.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/upload/Upload.js +5 -5
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/upload/Upload.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/utilities/Utilities.d.ts +4 -4
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/utilities/Utilities.d.ts.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/utilities/Utilities.js +10 -33
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/utilities/Utilities.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/utils/ZosFilesUtils.d.ts +7 -0
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/utils/ZosFilesUtils.d.ts.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/utils/ZosFilesUtils.js +16 -0
- package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/utils/ZosFilesUtils.js.map +1 -1
- package/node_modules/@zowe/zos-files-for-zowe-sdk/package.json +5 -5
- package/node_modules/@zowe/zos-jobs-for-zowe-sdk/package.json +5 -5
- package/node_modules/@zowe/zos-logs-for-zowe-sdk/package.json +4 -4
- package/node_modules/@zowe/zos-tso-for-zowe-sdk/package.json +5 -5
- package/node_modules/@zowe/zos-uss-for-zowe-sdk/package.json +3 -3
- package/node_modules/@zowe/zos-workflows-for-zowe-sdk/package.json +5 -5
- package/node_modules/@zowe/zosmf-for-zowe-sdk/lib/constants/Zosmf.constants.d.ts.map +1 -1
- package/node_modules/@zowe/zosmf-for-zowe-sdk/lib/constants/Zosmf.constants.js +21 -0
- package/node_modules/@zowe/zosmf-for-zowe-sdk/lib/constants/Zosmf.constants.js.map +1 -1
- package/node_modules/@zowe/zosmf-for-zowe-sdk/lib/constants/Zosmf.profile.d.ts.map +1 -1
- package/node_modules/@zowe/zosmf-for-zowe-sdk/lib/constants/Zosmf.profile.js +8 -0
- package/node_modules/@zowe/zosmf-for-zowe-sdk/lib/constants/Zosmf.profile.js.map +1 -1
- package/node_modules/@zowe/zosmf-for-zowe-sdk/package.json +4 -4
- package/node_modules/js-yaml/dist/js-yaml.js +11 -3
- package/node_modules/js-yaml/dist/js-yaml.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.min.js +1 -1
- package/node_modules/js-yaml/dist/js-yaml.min.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.mjs +11 -3
- package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
- package/node_modules/js-yaml/lib/loader.js +16 -3
- package/node_modules/js-yaml/package.json +1 -1
- package/node_modules/sanitize-html/README.md +13 -0
- package/node_modules/sanitize-html/index.js +86 -12
- package/node_modules/sanitize-html/node_modules/dom-serializer/LICENSE +7 -0
- package/node_modules/{dom-serializer → sanitize-html/node_modules/dom-serializer}/README.md +14 -8
- package/node_modules/sanitize-html/node_modules/dom-serializer/dist/foreign-names.d.ts +11 -0
- package/node_modules/sanitize-html/node_modules/dom-serializer/dist/foreign-names.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/dom-serializer/dist/foreign-names.js +15 -0
- package/node_modules/sanitize-html/node_modules/dom-serializer/dist/foreign-names.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/dom-serializer/dist/index.d.ts +72 -0
- package/node_modules/sanitize-html/node_modules/dom-serializer/dist/index.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/dom-serializer/dist/index.js +173 -0
- package/node_modules/sanitize-html/node_modules/dom-serializer/dist/index.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/dom-serializer/package.json +69 -0
- package/node_modules/sanitize-html/node_modules/dom-serializer/src/foreign-names.ts +19 -0
- package/node_modules/sanitize-html/node_modules/dom-serializer/src/index.ts +315 -0
- package/node_modules/{domelementtype/lib → sanitize-html/node_modules/domelementtype/dist}/index.d.ts +12 -12
- package/node_modules/sanitize-html/node_modules/domelementtype/dist/index.d.ts.map +1 -0
- package/node_modules/{domelementtype/lib/esm → sanitize-html/node_modules/domelementtype/dist}/index.js +15 -6
- package/node_modules/sanitize-html/node_modules/domelementtype/package.json +59 -0
- package/node_modules/{domhandler/lib → sanitize-html/node_modules/domhandler/dist}/index.d.ts +9 -6
- package/node_modules/sanitize-html/node_modules/domhandler/dist/index.d.ts.map +1 -0
- package/node_modules/{domhandler/lib/esm → sanitize-html/node_modules/domhandler/dist}/index.js +34 -25
- package/node_modules/{domhandler/lib → sanitize-html/node_modules/domhandler/dist}/node.d.ts +34 -15
- package/node_modules/sanitize-html/node_modules/domhandler/dist/node.d.ts.map +1 -0
- package/node_modules/{domhandler/lib/esm → sanitize-html/node_modules/domhandler/dist}/node.js +81 -60
- package/node_modules/sanitize-html/node_modules/domhandler/package.json +65 -0
- package/node_modules/{domhandler → sanitize-html/node_modules/domhandler}/readme.md +1 -7
- package/node_modules/{domutils/lib → sanitize-html/node_modules/domutils/dist}/feeds.d.ts +2 -2
- package/node_modules/sanitize-html/node_modules/domutils/dist/feeds.d.ts.map +1 -0
- package/node_modules/{domutils/lib/esm → sanitize-html/node_modules/domutils/dist}/feeds.js +22 -25
- package/node_modules/sanitize-html/node_modules/domutils/dist/feeds.js.map +1 -0
- package/node_modules/{domutils/lib → sanitize-html/node_modules/domutils/dist}/helpers.d.ts +1 -1
- package/node_modules/sanitize-html/node_modules/domutils/dist/helpers.d.ts.map +1 -0
- package/node_modules/{domutils/lib/esm → sanitize-html/node_modules/domutils/dist}/helpers.js +16 -16
- package/node_modules/sanitize-html/node_modules/domutils/dist/helpers.js.map +1 -0
- package/node_modules/{domutils/lib/esm → sanitize-html/node_modules/domutils/dist}/index.d.ts +5 -7
- package/node_modules/sanitize-html/node_modules/domutils/dist/index.d.ts.map +1 -0
- package/node_modules/{domutils/lib/esm → sanitize-html/node_modules/domutils/dist}/index.js +5 -7
- package/node_modules/sanitize-html/node_modules/domutils/dist/index.js.map +1 -0
- package/node_modules/{domutils/lib/esm → sanitize-html/node_modules/domutils/dist}/legacy.d.ts +1 -1
- package/node_modules/sanitize-html/node_modules/domutils/dist/legacy.d.ts.map +1 -0
- package/node_modules/{domutils/lib/esm → sanitize-html/node_modules/domutils/dist}/legacy.js +15 -15
- package/node_modules/sanitize-html/node_modules/domutils/dist/legacy.js.map +1 -0
- package/node_modules/{domutils/lib/esm → sanitize-html/node_modules/domutils/dist}/manipulation.d.ts +9 -9
- package/node_modules/sanitize-html/node_modules/domutils/dist/manipulation.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/domutils/dist/manipulation.js +138 -0
- package/node_modules/sanitize-html/node_modules/domutils/dist/manipulation.js.map +1 -0
- package/node_modules/{domutils/lib → sanitize-html/node_modules/domutils/dist}/querying.d.ts +6 -16
- package/node_modules/sanitize-html/node_modules/domutils/dist/querying.d.ts.map +1 -0
- package/node_modules/{domutils/lib/esm → sanitize-html/node_modules/domutils/dist}/querying.js +13 -26
- package/node_modules/sanitize-html/node_modules/domutils/dist/querying.js.map +1 -0
- package/node_modules/{domutils/lib → sanitize-html/node_modules/domutils/dist}/stringify.d.ts +2 -2
- package/node_modules/sanitize-html/node_modules/domutils/dist/stringify.d.ts.map +1 -0
- package/node_modules/{domutils/lib/esm → sanitize-html/node_modules/domutils/dist}/stringify.js +1 -1
- package/node_modules/sanitize-html/node_modules/domutils/dist/stringify.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/domutils/dist/traversal.d.ts +74 -0
- package/node_modules/sanitize-html/node_modules/domutils/dist/traversal.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/domutils/dist/traversal.js +105 -0
- package/node_modules/sanitize-html/node_modules/domutils/dist/traversal.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/domutils/package.json +69 -0
- package/node_modules/{domutils → sanitize-html/node_modules/domutils}/readme.md +0 -6
- package/node_modules/sanitize-html/node_modules/domutils/src/__snapshots__/feeds.spec.ts.snap +103 -0
- package/node_modules/sanitize-html/node_modules/domutils/src/feeds.ts +301 -0
- package/node_modules/{domutils/lib/helpers.js → sanitize-html/node_modules/domutils/src/helpers.ts} +55 -43
- package/node_modules/{domutils/lib/index.d.ts → sanitize-html/node_modules/domutils/src/index.ts} +5 -8
- package/node_modules/sanitize-html/node_modules/domutils/src/legacy.ts +224 -0
- package/node_modules/sanitize-html/node_modules/domutils/src/manipulation.ts +156 -0
- package/node_modules/{domutils/lib/querying.js → sanitize-html/node_modules/domutils/src/querying.ts} +77 -60
- package/node_modules/sanitize-html/node_modules/domutils/src/stringify.ts +90 -0
- package/node_modules/sanitize-html/node_modules/domutils/src/traversal.ts +132 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/decode-codepoint.d.ts +28 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/decode-codepoint.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/decode-codepoint.js +61 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/decode-codepoint.js.map +1 -0
- package/node_modules/{htmlparser2/node_modules/entities/dist/commonjs → sanitize-html/node_modules/entities/dist}/decode.d.ts +66 -44
- package/node_modules/sanitize-html/node_modules/entities/dist/decode.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/decode.js +1132 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/decode.js.map +1 -0
- package/node_modules/{htmlparser2/node_modules/entities/dist/commonjs → sanitize-html/node_modules/entities/dist}/encode.d.ts +4 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/encode.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/encode.js +295 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/encode.js.map +1 -0
- package/node_modules/{htmlparser2/node_modules/entities/dist/commonjs → sanitize-html/node_modules/entities/dist}/escape.d.ts +23 -9
- package/node_modules/sanitize-html/node_modules/entities/dist/escape.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/escape.js +172 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/escape.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/decode-data-html.d.ts +3 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/decode-data-html.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/decode-data-html.js +5 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/decode-data-html.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/decode-data-xml.d.ts +3 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/decode-data-xml.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/decode-data-xml.js +7 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/decode-data-xml.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/encode-html.d.ts +3 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/encode-html.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/encode-html.js +3 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/generated/encode-html.js.map +1 -0
- package/node_modules/{htmlparser2/node_modules/entities/dist/commonjs → sanitize-html/node_modules/entities/dist}/index.d.ts +11 -18
- package/node_modules/sanitize-html/node_modules/entities/dist/index.d.ts.map +1 -0
- package/node_modules/{htmlparser2/node_modules/entities/dist/esm → sanitize-html/node_modules/entities/dist}/index.js +9 -29
- package/node_modules/sanitize-html/node_modules/entities/dist/index.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/internal/bin-trie-flags.d.ts +48 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/internal/bin-trie-flags.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/internal/bin-trie-flags.js +49 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/internal/bin-trie-flags.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/internal/decode-shared.d.ts +38 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/internal/decode-shared.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/internal/decode-shared.js +195 -0
- package/node_modules/sanitize-html/node_modules/entities/dist/internal/decode-shared.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/entities/package.json +83 -0
- package/node_modules/{htmlparser2 → sanitize-html}/node_modules/entities/readme.md +4 -16
- package/node_modules/sanitize-html/node_modules/entities/src/decode-codepoint.ts +69 -0
- package/node_modules/sanitize-html/node_modules/entities/src/decode.ts +1368 -0
- package/node_modules/sanitize-html/node_modules/entities/src/encode.ts +337 -0
- package/node_modules/sanitize-html/node_modules/entities/src/escape.ts +187 -0
- package/node_modules/sanitize-html/node_modules/entities/src/generated/decode-data-html.ts +12 -0
- package/node_modules/sanitize-html/node_modules/entities/src/generated/decode-data-xml.ts +7 -0
- package/node_modules/sanitize-html/node_modules/entities/src/generated/encode-html.ts +3 -0
- package/node_modules/{htmlparser2 → sanitize-html}/node_modules/entities/src/index.ts +14 -41
- package/node_modules/sanitize-html/node_modules/entities/src/internal/bin-trie-flags.ts +47 -0
- package/node_modules/sanitize-html/node_modules/entities/src/internal/decode-shared.ts +209 -0
- package/node_modules/sanitize-html/node_modules/htmlparser2/README.md +257 -0
- package/node_modules/{htmlparser2/dist/esm → sanitize-html/node_modules/htmlparser2/dist}/Parser.d.ts +97 -38
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/Parser.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/Parser.js +644 -0
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/Parser.js.map +1 -0
- package/node_modules/{htmlparser2/dist/commonjs → sanitize-html/node_modules/htmlparser2/dist}/Tokenizer.d.ts +75 -7
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/Tokenizer.d.ts.map +1 -0
- package/node_modules/{htmlparser2/dist/esm → sanitize-html/node_modules/htmlparser2/dist}/Tokenizer.js +434 -179
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/Tokenizer.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/WebWritableStream.d.ts +24 -0
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/WebWritableStream.d.ts.map +1 -0
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/WebWritableStream.js +44 -0
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/WebWritableStream.js.map +1 -0
- package/node_modules/{htmlparser2/dist/commonjs → sanitize-html/node_modules/htmlparser2/dist}/WritableStream.d.ts +1 -2
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/WritableStream.d.ts.map +1 -0
- package/node_modules/{htmlparser2/dist/esm → sanitize-html/node_modules/htmlparser2/dist}/WritableStream.js +3 -3
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/WritableStream.js.map +1 -0
- package/node_modules/{htmlparser2/dist/commonjs → sanitize-html/node_modules/htmlparser2/dist}/index.d.ts +6 -26
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/index.d.ts.map +1 -0
- package/node_modules/{htmlparser2/dist/esm → sanitize-html/node_modules/htmlparser2/dist}/index.js +2 -30
- package/node_modules/sanitize-html/node_modules/htmlparser2/dist/index.js.map +1 -0
- package/node_modules/sanitize-html/node_modules/htmlparser2/package.json +86 -0
- package/node_modules/{htmlparser2 → sanitize-html/node_modules/htmlparser2}/src/Parser.ts +260 -100
- package/node_modules/{htmlparser2 → sanitize-html/node_modules/htmlparser2}/src/Tokenizer.ts +438 -165
- package/node_modules/sanitize-html/node_modules/htmlparser2/src/WebWritableStream.ts +47 -0
- package/node_modules/{htmlparser2 → sanitize-html/node_modules/htmlparser2}/src/WritableStream.ts +1 -2
- package/node_modules/{htmlparser2 → sanitize-html/node_modules/htmlparser2}/src/index.ts +14 -43
- package/node_modules/sanitize-html/package.json +5 -2
- package/package.json +15 -15
- package/scripts/validateSecretsPrebuild.js +231 -0
- package/node_modules/dom-serializer/LICENSE +0 -11
- package/node_modules/dom-serializer/lib/esm/foreignNames.d.ts +0 -3
- package/node_modules/dom-serializer/lib/esm/foreignNames.d.ts.map +0 -1
- package/node_modules/dom-serializer/lib/esm/foreignNames.js +0 -100
- package/node_modules/dom-serializer/lib/esm/index.d.ts +0 -52
- package/node_modules/dom-serializer/lib/esm/index.d.ts.map +0 -1
- package/node_modules/dom-serializer/lib/esm/index.js +0 -190
- package/node_modules/dom-serializer/lib/esm/package.json +0 -1
- package/node_modules/dom-serializer/lib/foreignNames.d.ts +0 -3
- package/node_modules/dom-serializer/lib/foreignNames.d.ts.map +0 -1
- package/node_modules/dom-serializer/lib/foreignNames.js +0 -103
- package/node_modules/dom-serializer/lib/index.d.ts +0 -52
- package/node_modules/dom-serializer/lib/index.d.ts.map +0 -1
- package/node_modules/dom-serializer/lib/index.js +0 -229
- package/node_modules/dom-serializer/package.json +0 -69
- package/node_modules/domelementtype/lib/esm/index.d.ts +0 -48
- package/node_modules/domelementtype/lib/esm/index.d.ts.map +0 -1
- package/node_modules/domelementtype/lib/esm/package.json +0 -1
- package/node_modules/domelementtype/lib/index.d.ts.map +0 -1
- package/node_modules/domelementtype/lib/index.js +0 -55
- package/node_modules/domelementtype/package.json +0 -54
- package/node_modules/domhandler/lib/esm/index.d.ts +0 -76
- package/node_modules/domhandler/lib/esm/index.d.ts.map +0 -1
- package/node_modules/domhandler/lib/esm/node.d.ts +0 -245
- package/node_modules/domhandler/lib/esm/node.d.ts.map +0 -1
- package/node_modules/domhandler/lib/esm/package.json +0 -1
- package/node_modules/domhandler/lib/index.d.ts.map +0 -1
- package/node_modules/domhandler/lib/index.js +0 -165
- package/node_modules/domhandler/lib/node.d.ts.map +0 -1
- package/node_modules/domhandler/lib/node.js +0 -474
- package/node_modules/domhandler/package.json +0 -73
- package/node_modules/domutils/lib/esm/feeds.d.ts +0 -71
- package/node_modules/domutils/lib/esm/feeds.d.ts.map +0 -1
- package/node_modules/domutils/lib/esm/feeds.js.map +0 -1
- package/node_modules/domutils/lib/esm/helpers.d.ts +0 -59
- package/node_modules/domutils/lib/esm/helpers.d.ts.map +0 -1
- package/node_modules/domutils/lib/esm/helpers.js.map +0 -1
- package/node_modules/domutils/lib/esm/index.d.ts.map +0 -1
- package/node_modules/domutils/lib/esm/index.js.map +0 -1
- package/node_modules/domutils/lib/esm/legacy.d.ts.map +0 -1
- package/node_modules/domutils/lib/esm/legacy.js.map +0 -1
- package/node_modules/domutils/lib/esm/manipulation.d.ts.map +0 -1
- package/node_modules/domutils/lib/esm/manipulation.js +0 -134
- package/node_modules/domutils/lib/esm/manipulation.js.map +0 -1
- package/node_modules/domutils/lib/esm/package.json +0 -1
- package/node_modules/domutils/lib/esm/querying.d.ts +0 -64
- package/node_modules/domutils/lib/esm/querying.d.ts.map +0 -1
- package/node_modules/domutils/lib/esm/querying.js.map +0 -1
- package/node_modules/domutils/lib/esm/stringify.d.ts +0 -46
- package/node_modules/domutils/lib/esm/stringify.d.ts.map +0 -1
- package/node_modules/domutils/lib/esm/stringify.js.map +0 -1
- package/node_modules/domutils/lib/esm/traversal.d.ts +0 -67
- package/node_modules/domutils/lib/esm/traversal.d.ts.map +0 -1
- package/node_modules/domutils/lib/esm/traversal.js +0 -112
- package/node_modules/domutils/lib/esm/traversal.js.map +0 -1
- package/node_modules/domutils/lib/feeds.d.ts.map +0 -1
- package/node_modules/domutils/lib/feeds.js +0 -190
- package/node_modules/domutils/lib/feeds.js.map +0 -1
- package/node_modules/domutils/lib/helpers.d.ts.map +0 -1
- package/node_modules/domutils/lib/helpers.js.map +0 -1
- package/node_modules/domutils/lib/index.d.ts.map +0 -1
- package/node_modules/domutils/lib/index.js +0 -33
- package/node_modules/domutils/lib/index.js.map +0 -1
- package/node_modules/domutils/lib/legacy.d.ts +0 -79
- package/node_modules/domutils/lib/legacy.d.ts.map +0 -1
- package/node_modules/domutils/lib/legacy.js +0 -168
- package/node_modules/domutils/lib/legacy.js.map +0 -1
- package/node_modules/domutils/lib/manipulation.d.ts +0 -49
- package/node_modules/domutils/lib/manipulation.d.ts.map +0 -1
- package/node_modules/domutils/lib/manipulation.js +0 -142
- package/node_modules/domutils/lib/manipulation.js.map +0 -1
- package/node_modules/domutils/lib/querying.d.ts.map +0 -1
- package/node_modules/domutils/lib/querying.js.map +0 -1
- package/node_modules/domutils/lib/stringify.d.ts.map +0 -1
- package/node_modules/domutils/lib/stringify.js +0 -91
- package/node_modules/domutils/lib/stringify.js.map +0 -1
- package/node_modules/domutils/lib/traversal.d.ts +0 -67
- package/node_modules/domutils/lib/traversal.d.ts.map +0 -1
- package/node_modules/domutils/lib/traversal.js +0 -125
- package/node_modules/domutils/lib/traversal.js.map +0 -1
- package/node_modules/domutils/package.json +0 -79
- package/node_modules/htmlparser2/README.md +0 -171
- package/node_modules/htmlparser2/WritableStream.js +0 -3
- package/node_modules/htmlparser2/dist/commonjs/Parser.d.ts +0 -198
- package/node_modules/htmlparser2/dist/commonjs/Parser.d.ts.map +0 -1
- package/node_modules/htmlparser2/dist/commonjs/Parser.js +0 -527
- package/node_modules/htmlparser2/dist/commonjs/Parser.js.map +0 -1
- package/node_modules/htmlparser2/dist/commonjs/Tokenizer.d.ts.map +0 -1
- package/node_modules/htmlparser2/dist/commonjs/Tokenizer.js +0 -805
- package/node_modules/htmlparser2/dist/commonjs/Tokenizer.js.map +0 -1
- package/node_modules/htmlparser2/dist/commonjs/WritableStream.d.ts.map +0 -1
- package/node_modules/htmlparser2/dist/commonjs/WritableStream.js +0 -36
- package/node_modules/htmlparser2/dist/commonjs/WritableStream.js.map +0 -1
- package/node_modules/htmlparser2/dist/commonjs/index.d.ts.map +0 -1
- package/node_modules/htmlparser2/dist/commonjs/index.js +0 -123
- package/node_modules/htmlparser2/dist/commonjs/index.js.map +0 -1
- package/node_modules/htmlparser2/dist/commonjs/package.json +0 -3
- package/node_modules/htmlparser2/dist/esm/Parser.d.ts.map +0 -1
- package/node_modules/htmlparser2/dist/esm/Parser.js +0 -490
- package/node_modules/htmlparser2/dist/esm/Parser.js.map +0 -1
- package/node_modules/htmlparser2/dist/esm/Tokenizer.d.ts +0 -126
- package/node_modules/htmlparser2/dist/esm/Tokenizer.d.ts.map +0 -1
- package/node_modules/htmlparser2/dist/esm/Tokenizer.js.map +0 -1
- package/node_modules/htmlparser2/dist/esm/WritableStream.d.ts +0 -15
- package/node_modules/htmlparser2/dist/esm/WritableStream.d.ts.map +0 -1
- package/node_modules/htmlparser2/dist/esm/WritableStream.js.map +0 -1
- package/node_modules/htmlparser2/dist/esm/index.d.ts +0 -54
- package/node_modules/htmlparser2/dist/esm/index.d.ts.map +0 -1
- package/node_modules/htmlparser2/dist/esm/index.js.map +0 -1
- package/node_modules/htmlparser2/dist/esm/package.json +0 -3
- package/node_modules/htmlparser2/node_modules/entities/decode.d.ts +0 -3
- package/node_modules/htmlparser2/node_modules/entities/decode.js +0 -3
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/decode-codepoint.d.ts +0 -19
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/decode-codepoint.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/decode-codepoint.js +0 -77
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/decode-codepoint.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/decode.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/decode.js +0 -568
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/decode.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/encode.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/encode.js +0 -92
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/encode.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/escape.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/escape.js +0 -138
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/escape.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/decode-data-html.d.ts +0 -2
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/decode-data-html.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/decode-data-html.js +0 -7
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/decode-data-html.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/decode-data-xml.d.ts +0 -2
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/decode-data-xml.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +0 -7
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/decode-data-xml.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/encode-html.d.ts +0 -3
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/encode-html.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/encode-html.js +0 -14
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/generated/encode-html.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/index.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/index.js +0 -131
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/index.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/bin-trie-flags.d.ts +0 -17
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/bin-trie-flags.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +0 -21
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/decode-shared.d.ts +0 -2
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/decode-shared.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/decode-shared.js +0 -31
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/decode-shared.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/encode-shared.d.ts +0 -32
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/encode-shared.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/encode-shared.js +0 -94
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/internal/encode-shared.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/commonjs/package.json +0 -3
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/decode-codepoint.d.ts +0 -19
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/decode-codepoint.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/decode-codepoint.js +0 -72
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/decode-codepoint.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/decode.d.ts +0 -205
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/decode.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/decode.js +0 -554
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/decode.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/encode.d.ts +0 -22
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/encode.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/encode.js +0 -88
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/encode.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/escape.d.ts +0 -46
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/escape.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/escape.js +0 -134
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/escape.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/decode-data-html.d.ts +0 -2
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/decode-data-html.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/decode-data-html.js +0 -4
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/decode-data-html.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/decode-data-xml.d.ts +0 -2
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/decode-data-xml.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/decode-data-xml.js +0 -4
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/decode-data-xml.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/encode-html.d.ts +0 -3
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/encode-html.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/encode-html.js +0 -11
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/generated/encode-html.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/index.d.ts +0 -96
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/index.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/index.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/bin-trie-flags.d.ts +0 -17
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/bin-trie-flags.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/bin-trie-flags.js +0 -18
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/bin-trie-flags.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/decode-shared.d.ts +0 -2
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/decode-shared.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/decode-shared.js +0 -28
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/decode-shared.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/encode-shared.d.ts +0 -32
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/encode-shared.d.ts.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/encode-shared.js +0 -91
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/internal/encode-shared.js.map +0 -1
- package/node_modules/htmlparser2/node_modules/entities/dist/esm/package.json +0 -3
- package/node_modules/htmlparser2/node_modules/entities/escape.d.ts +0 -3
- package/node_modules/htmlparser2/node_modules/entities/escape.js +0 -3
- package/node_modules/htmlparser2/node_modules/entities/package.json +0 -120
- package/node_modules/htmlparser2/node_modules/entities/src/decode-codepoint.ts +0 -81
- package/node_modules/htmlparser2/node_modules/entities/src/decode.ts +0 -685
- package/node_modules/htmlparser2/node_modules/entities/src/encode.ts +0 -93
- package/node_modules/htmlparser2/node_modules/entities/src/escape.ts +0 -161
- package/node_modules/htmlparser2/node_modules/entities/src/generated/.eslintrc.json +0 -10
- package/node_modules/htmlparser2/node_modules/entities/src/generated/decode-data-html.ts +0 -6
- package/node_modules/htmlparser2/node_modules/entities/src/generated/decode-data-xml.ts +0 -6
- package/node_modules/htmlparser2/node_modules/entities/src/generated/encode-html.ts +0 -17
- package/node_modules/htmlparser2/node_modules/entities/src/internal/bin-trie-flags.ts +0 -16
- package/node_modules/htmlparser2/node_modules/entities/src/internal/decode-shared.ts +0 -30
- package/node_modules/htmlparser2/node_modules/entities/src/internal/encode-shared.ts +0 -121
- package/node_modules/htmlparser2/package.json +0 -113
- /package/node_modules/{domelementtype → sanitize-html/node_modules/domelementtype}/LICENSE +0 -0
- /package/node_modules/{domelementtype → sanitize-html/node_modules/domelementtype}/readme.md +0 -0
- /package/node_modules/{domhandler → sanitize-html/node_modules/domhandler}/LICENSE +0 -0
- /package/node_modules/{domutils → sanitize-html/node_modules/domutils}/LICENSE +0 -0
- /package/node_modules/{htmlparser2 → sanitize-html}/node_modules/entities/LICENSE +0 -0
- /package/node_modules/{htmlparser2 → sanitize-html/node_modules/htmlparser2}/LICENSE +0 -0
|
@@ -0,0 +1,1368 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codePointToString,
|
|
3
|
+
replaceCodePoint,
|
|
4
|
+
replaceCodePointXML,
|
|
5
|
+
} from "./decode-codepoint.js";
|
|
6
|
+
import { htmlDecodeTree } from "./generated/decode-data-html.js";
|
|
7
|
+
import { xmlDecodeTree } from "./generated/decode-data-xml.js";
|
|
8
|
+
import { BinTrieFlags } from "./internal/bin-trie-flags.js";
|
|
9
|
+
|
|
10
|
+
const enum CharCodes {
|
|
11
|
+
AMP = 38, // "&"
|
|
12
|
+
NUM = 35, // "#"
|
|
13
|
+
SEMI = 59, // ";"
|
|
14
|
+
EQUALS = 61, // "="
|
|
15
|
+
ZERO = 48, // "0"
|
|
16
|
+
NINE = 57, // "9"
|
|
17
|
+
LOWER_A = 97, // "a"
|
|
18
|
+
LOWER_X = 120, // "x"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Bit that needs to be set to convert an upper case ASCII character to lower case */
|
|
22
|
+
const TO_LOWER_BIT = 0b10_0000;
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* `parseNumericEntity` packs its two results into one 32-bit integer:
|
|
26
|
+
* `(consumed << CONSUMED_SHIFT) | codePoint`. The 21-bit code point field
|
|
27
|
+
* fits any valid Unicode value (max 0x10FFFF, clamped before packing); the
|
|
28
|
+
* consumed count excludes `&` and gets the remaining 11 bits. Extract it
|
|
29
|
+
* with `>>>` so the topmost bit isn't treated as a sign.
|
|
30
|
+
*
|
|
31
|
+
* Plain consts rather than a `const enum`: with `isolatedModules`, enum
|
|
32
|
+
* member reads compile to runtime property loads.
|
|
33
|
+
*/
|
|
34
|
+
const CONSUMED_SHIFT = 21;
|
|
35
|
+
const CODE_POINT_MASK = 0x1f_ff_ff;
|
|
36
|
+
/**
|
|
37
|
+
* Reserved consumed field for counts of at least 2047 characters after `&`.
|
|
38
|
+
* The true count is in `longNumericConsumed`.
|
|
39
|
+
*/
|
|
40
|
+
const CONSUMED_OVERFLOW = 0x7_ff;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Side channel for numeric entities of at least 2048 characters including
|
|
44
|
+
* `&`. Set by `parseNumericEntity` when its consumed count reaches the
|
|
45
|
+
* reserved value `CONSUMED_OVERFLOW`; callers read the true count from here.
|
|
46
|
+
* A module-level slot avoids a tuple allocation on the hot path.
|
|
47
|
+
*/
|
|
48
|
+
let longNumericConsumed = 0;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Extract the consumed count from a `parseNumericEntity` packed result,
|
|
52
|
+
* recovering the true length from `longNumericConsumed` when the packed
|
|
53
|
+
* field contains the sentinel. Read it before the next `parseNumericEntity`
|
|
54
|
+
* call, which may overwrite the side channel. This helper owns that protocol.
|
|
55
|
+
* @param packed Packed result of `parseNumericEntity`.
|
|
56
|
+
*/
|
|
57
|
+
function unpackConsumed(packed: number): number {
|
|
58
|
+
const consumed = packed >>> CONSUMED_SHIFT;
|
|
59
|
+
return consumed === CONSUMED_OVERFLOW ? longNumericConsumed : consumed;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Unsigned subtraction trick: (code - lo) >>> 0 wraps negatives to large
|
|
64
|
+
* values, so a single `<=` covers the entire [lo..hi] range check.
|
|
65
|
+
* @param code Code point to check.
|
|
66
|
+
*/
|
|
67
|
+
function isNumber(code: number): boolean {
|
|
68
|
+
return (code - CharCodes.ZERO) >>> 0 <= 9;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function isHexadecimalCharacter(code: number): boolean {
|
|
72
|
+
return ((code | TO_LOWER_BIT) - CharCodes.LOWER_A) >>> 0 <= 5; // F - a
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function isAlpha(code: number): boolean {
|
|
76
|
+
return ((code | TO_LOWER_BIT) - CharCodes.LOWER_A) >>> 0 <= 25; // Z - a
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Checks if the given character is a valid end character for an entity in an attribute.
|
|
81
|
+
*
|
|
82
|
+
* Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
|
|
83
|
+
* See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
|
|
84
|
+
* @param code Code point to check.
|
|
85
|
+
*/
|
|
86
|
+
function isEntityInAttributeInvalidEnd(code: number): boolean {
|
|
87
|
+
return code === CharCodes.EQUALS || isAlpha(code) || isNumber(code);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const enum EntityDecoderState {
|
|
91
|
+
EntityStart,
|
|
92
|
+
NumericStart,
|
|
93
|
+
NumericDecimal,
|
|
94
|
+
NumericHex,
|
|
95
|
+
NamedEntity,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Decoding mode for named entities.
|
|
100
|
+
*/
|
|
101
|
+
export enum DecodingMode {
|
|
102
|
+
/** Entities in text nodes that can end with any character. */
|
|
103
|
+
Legacy = 0,
|
|
104
|
+
/** Only allow entities terminated with a semicolon. */
|
|
105
|
+
Strict = 1,
|
|
106
|
+
/** Entities in attributes have limitations on ending characters. */
|
|
107
|
+
Attribute = 2,
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Producers for character reference errors as defined in the HTML spec.
|
|
112
|
+
*/
|
|
113
|
+
export interface EntityErrorProducer {
|
|
114
|
+
missingSemicolonAfterCharacterReference(): void;
|
|
115
|
+
absenceOfDigitsInNumericCharacterReference(
|
|
116
|
+
consumedCharacters: number,
|
|
117
|
+
): void;
|
|
118
|
+
/**
|
|
119
|
+
* Validate the accumulated numeric value, before Unicode replacement.
|
|
120
|
+
* Values beyond the JavaScript number range are positive infinity.
|
|
121
|
+
*/
|
|
122
|
+
validateNumericCharacterReference(code: number): void;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Token decoder with support of writing partial entities.
|
|
127
|
+
*/
|
|
128
|
+
export class EntityDecoder {
|
|
129
|
+
/** The current state of the decoder. */
|
|
130
|
+
private state: number = EntityDecoderState.EntityStart;
|
|
131
|
+
/** Characters that were consumed while parsing an entity. */
|
|
132
|
+
private consumed = 1;
|
|
133
|
+
/**
|
|
134
|
+
* The result of the entity.
|
|
135
|
+
*
|
|
136
|
+
* For named entities: the trie index of the best legacy match so far
|
|
137
|
+
* (0 = none). For numeric entities: the accumulated code point.
|
|
138
|
+
*/
|
|
139
|
+
private result = 0;
|
|
140
|
+
|
|
141
|
+
/** The current index in the decode tree. */
|
|
142
|
+
private treeIndex = 0;
|
|
143
|
+
/**
|
|
144
|
+
* Characters consumed since the last recorded legacy match, plus one.
|
|
145
|
+
* Invariant at the top of the `stateNamedEntity` loop: `excess` equals
|
|
146
|
+
* the number of unrecorded consumed characters + 1.
|
|
147
|
+
*/
|
|
148
|
+
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: False positive (read via destructuring)
|
|
149
|
+
private excess = 1;
|
|
150
|
+
/** The mode in which the decoder is operating. */
|
|
151
|
+
private decodeMode = DecodingMode.Strict;
|
|
152
|
+
/** The number of characters that have been consumed in the current run. */
|
|
153
|
+
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: False positive
|
|
154
|
+
private runConsumed = 0;
|
|
155
|
+
|
|
156
|
+
constructor(
|
|
157
|
+
/** The predefined HTML or XML decode tree. */
|
|
158
|
+
private readonly decodeTree: Uint16Array,
|
|
159
|
+
/**
|
|
160
|
+
* The function that is called when a codepoint is decoded.
|
|
161
|
+
*
|
|
162
|
+
* For named entities that decode to multiple code points, this will
|
|
163
|
+
* be called multiple times, with the second codepoint, and the same
|
|
164
|
+
* `consumed` value.
|
|
165
|
+
* @param codepoint The decoded codepoint.
|
|
166
|
+
* @param consumed The number of characters consumed by the decoder.
|
|
167
|
+
*/
|
|
168
|
+
private readonly emitCodePoint: (cp: number, consumed: number) => void,
|
|
169
|
+
/** An object that is used to produce errors. */
|
|
170
|
+
private readonly errors?: EntityErrorProducer | undefined,
|
|
171
|
+
) {}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Resets the instance to make it reusable.
|
|
175
|
+
* @param decodeMode Entity decoding mode to use.
|
|
176
|
+
*/
|
|
177
|
+
startEntity(decodeMode: DecodingMode): void {
|
|
178
|
+
this.decodeMode = decodeMode;
|
|
179
|
+
this.state = EntityDecoderState.EntityStart;
|
|
180
|
+
this.result = 0;
|
|
181
|
+
this.treeIndex = 0;
|
|
182
|
+
this.excess = 1;
|
|
183
|
+
this.consumed = 1;
|
|
184
|
+
this.runConsumed = 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Write an entity to the decoder. This can be called multiple times with partial entities.
|
|
189
|
+
* If the entity is incomplete, the decoder will return -1.
|
|
190
|
+
*
|
|
191
|
+
* Mirrors the non-streaming `decodeWithTrie`, but with the ability to stop decoding if the
|
|
192
|
+
* entity is incomplete, and resume when the next string is written.
|
|
193
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
194
|
+
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
|
195
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
196
|
+
*/
|
|
197
|
+
write(input: string, offset: number): number {
|
|
198
|
+
switch (this.state) {
|
|
199
|
+
case EntityDecoderState.EntityStart: {
|
|
200
|
+
if (input.charCodeAt(offset) === CharCodes.NUM) {
|
|
201
|
+
this.state = EntityDecoderState.NumericStart;
|
|
202
|
+
this.consumed += 1;
|
|
203
|
+
return this.stateNumericStart(input, offset + 1);
|
|
204
|
+
}
|
|
205
|
+
this.state = EntityDecoderState.NamedEntity;
|
|
206
|
+
return this.stateNamedEntity(input, offset);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
case EntityDecoderState.NumericStart: {
|
|
210
|
+
return this.stateNumericStart(input, offset);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
case EntityDecoderState.NumericDecimal: {
|
|
214
|
+
return this.stateNumericDecimal(input, offset);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
case EntityDecoderState.NumericHex: {
|
|
218
|
+
return this.stateNumericHex(input, offset);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
default: {
|
|
222
|
+
// NamedEntity — the only remaining state.
|
|
223
|
+
return this.stateNamedEntity(input, offset);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Switches between the numeric decimal and hexadecimal states.
|
|
230
|
+
*
|
|
231
|
+
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
|
232
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
233
|
+
* @param offset The current offset.
|
|
234
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
235
|
+
*/
|
|
236
|
+
// eslint-disable-next-line unicorn/consistent-class-member-order
|
|
237
|
+
private stateNumericStart(input: string, offset: number): number {
|
|
238
|
+
if (offset >= input.length) {
|
|
239
|
+
return -1;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
|
|
243
|
+
this.state = EntityDecoderState.NumericHex;
|
|
244
|
+
this.consumed += 1;
|
|
245
|
+
return this.stateNumericHex(input, offset + 1);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
this.state = EntityDecoderState.NumericDecimal;
|
|
249
|
+
return this.stateNumericDecimal(input, offset);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Parses a hexadecimal numeric entity.
|
|
254
|
+
*
|
|
255
|
+
* Equivalent to the `Hexademical character reference state` in the HTML
|
|
256
|
+
* spec. Digit parsing matches the hex loop in `parseNumericEntity`.
|
|
257
|
+
* The accumulated value is preserved for numeric validation callbacks.
|
|
258
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
259
|
+
* @param offset The current offset.
|
|
260
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
261
|
+
*/
|
|
262
|
+
private stateNumericHex(input: string, offset: number): number {
|
|
263
|
+
const inputLength = input.length;
|
|
264
|
+
// Local accumulators; flushed before any exit (see stateNamedEntity).
|
|
265
|
+
let { result } = this;
|
|
266
|
+
let { consumed } = this;
|
|
267
|
+
while (offset < inputLength) {
|
|
268
|
+
const char = input.charCodeAt(offset);
|
|
269
|
+
if (isNumber(char) || isHexadecimalCharacter(char)) {
|
|
270
|
+
// Convert hex digit to value (0-15); 'a'/'A' -> 10.
|
|
271
|
+
const digit =
|
|
272
|
+
char <= CharCodes.NINE
|
|
273
|
+
? char - CharCodes.ZERO
|
|
274
|
+
: (char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10;
|
|
275
|
+
result = result * 16 + digit;
|
|
276
|
+
consumed += 1;
|
|
277
|
+
offset += 1;
|
|
278
|
+
} else {
|
|
279
|
+
this.result = result;
|
|
280
|
+
this.consumed = consumed;
|
|
281
|
+
return this.emitNumericEntity(char, 3);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
this.result = result;
|
|
285
|
+
this.consumed = consumed;
|
|
286
|
+
return -1; // Incomplete entity
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Parses a decimal numeric entity.
|
|
291
|
+
*
|
|
292
|
+
* Equivalent to the `Decimal character reference state` in the HTML
|
|
293
|
+
* spec. Digit parsing matches the decimal loop in `parseNumericEntity`.
|
|
294
|
+
* The accumulated value is preserved for numeric validation callbacks.
|
|
295
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
296
|
+
* @param offset The current offset.
|
|
297
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
298
|
+
*/
|
|
299
|
+
private stateNumericDecimal(input: string, offset: number): number {
|
|
300
|
+
const inputLength = input.length;
|
|
301
|
+
// Local accumulators; flushed before any exit (see stateNamedEntity).
|
|
302
|
+
let { result } = this;
|
|
303
|
+
let { consumed } = this;
|
|
304
|
+
while (offset < inputLength) {
|
|
305
|
+
const digit = input.charCodeAt(offset) - CharCodes.ZERO;
|
|
306
|
+
if (digit >>> 0 > 9) {
|
|
307
|
+
this.result = result;
|
|
308
|
+
this.consumed = consumed;
|
|
309
|
+
return this.emitNumericEntity(digit + CharCodes.ZERO, 2);
|
|
310
|
+
}
|
|
311
|
+
result = result * 10 + digit;
|
|
312
|
+
consumed += 1;
|
|
313
|
+
offset += 1;
|
|
314
|
+
}
|
|
315
|
+
this.result = result;
|
|
316
|
+
this.consumed = consumed;
|
|
317
|
+
return -1; // Incomplete entity
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Validate and emit a numeric entity.
|
|
322
|
+
*
|
|
323
|
+
* Implements the logic from the `Hexademical character reference start
|
|
324
|
+
* state` and `Numeric character reference end state` in the HTML spec.
|
|
325
|
+
* @param lastCp The last code point of the entity. Used to see if the
|
|
326
|
+
* entity was terminated with a semicolon.
|
|
327
|
+
* @param expectedLength The minimum number of characters that should be
|
|
328
|
+
* consumed. Used to validate that at least one digit
|
|
329
|
+
* was consumed.
|
|
330
|
+
* @returns The number of characters that were consumed.
|
|
331
|
+
*/
|
|
332
|
+
private emitNumericEntity(lastCp: number, expectedLength: number): number {
|
|
333
|
+
// Ensure we consumed at least one digit.
|
|
334
|
+
if (this.consumed <= expectedLength) {
|
|
335
|
+
this.errors?.absenceOfDigitsInNumericCharacterReference(
|
|
336
|
+
this.consumed,
|
|
337
|
+
);
|
|
338
|
+
return 0;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Figure out if this is a legit end of the entity
|
|
342
|
+
if (lastCp === CharCodes.SEMI) {
|
|
343
|
+
this.consumed += 1;
|
|
344
|
+
} else if (this.decodeMode === DecodingMode.Strict) {
|
|
345
|
+
return 0;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
this.emitCodePoint(
|
|
349
|
+
(this.decodeTree === xmlDecodeTree
|
|
350
|
+
? replaceCodePointXML
|
|
351
|
+
: replaceCodePoint)(this.result),
|
|
352
|
+
this.consumed,
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
if (this.errors) {
|
|
356
|
+
if (lastCp !== CharCodes.SEMI) {
|
|
357
|
+
this.errors.missingSemicolonAfterCharacterReference();
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
this.errors.validateNumericCharacterReference(this.result);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return this.consumed;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Flush locally-tracked walk state back to the fields, then emit the
|
|
368
|
+
* recorded legacy match or reject (cold path — at most once per
|
|
369
|
+
* entity). Called after failed navigation (leaf node, branch miss, or
|
|
370
|
+
* compact-run mismatch). In attribute mode, reject if no legacy was
|
|
371
|
+
* recorded at the current node, if we descended past it, or if the
|
|
372
|
+
* pending input character is an invalid attribute terminator.
|
|
373
|
+
* @param consumed Locally-tracked consumed count.
|
|
374
|
+
* @param excess Locally-tracked excess count.
|
|
375
|
+
* @param char Pending input character (may be the mismatching char).
|
|
376
|
+
* @param valueLength Value length at the current trie node.
|
|
377
|
+
*/
|
|
378
|
+
private flushAndEmitLegacyOrReject(
|
|
379
|
+
consumed: number,
|
|
380
|
+
excess: number,
|
|
381
|
+
char: number,
|
|
382
|
+
valueLength: number,
|
|
383
|
+
): number {
|
|
384
|
+
this.consumed = consumed;
|
|
385
|
+
this.excess = excess;
|
|
386
|
+
return this.result === 0 ||
|
|
387
|
+
(this.decodeMode === DecodingMode.Attribute &&
|
|
388
|
+
(valueLength === 0 ||
|
|
389
|
+
excess > 1 ||
|
|
390
|
+
isEntityInAttributeInvalidEnd(char)))
|
|
391
|
+
? 0
|
|
392
|
+
: this.emitNotTerminatedNamedEntity();
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Parses a named entity.
|
|
397
|
+
*
|
|
398
|
+
* Equivalent to the `Named character reference state` in the HTML spec.
|
|
399
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
400
|
+
* @param offset The current offset.
|
|
401
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
402
|
+
*/
|
|
403
|
+
private stateNamedEntity(input: string, offset: number): number {
|
|
404
|
+
const { decodeTree } = this;
|
|
405
|
+
const inputLength = input.length;
|
|
406
|
+
const isStrict = this.decodeMode === DecodingMode.Strict;
|
|
407
|
+
|
|
408
|
+
/*
|
|
409
|
+
* Local copies of the resumable walk state avoid per-character
|
|
410
|
+
* field writes. They are flushed back to the fields
|
|
411
|
+
* on every exit (chunk end, and before any emit helper that reads
|
|
412
|
+
* them). `this.result` is only written at the (rare) record points,
|
|
413
|
+
* so it stays a direct field write.
|
|
414
|
+
*
|
|
415
|
+
* Legacy-match recording happens in two idempotent places: at the
|
|
416
|
+
* loop top when sitting on a value node, and in the chunk-end
|
|
417
|
+
* epilogue (so `end()` sees matches that land exactly on a chunk
|
|
418
|
+
* boundary). Recording applies `consumed += excess - 1; excess = 1`,
|
|
419
|
+
* which is a no-op when repeated — the loop-top invariant is
|
|
420
|
+
* `excess` = unrecorded consumed characters + 1.
|
|
421
|
+
*/
|
|
422
|
+
let { treeIndex } = this;
|
|
423
|
+
let { excess } = this;
|
|
424
|
+
let { consumed } = this;
|
|
425
|
+
let current = decodeTree[treeIndex];
|
|
426
|
+
|
|
427
|
+
while (offset < inputLength) {
|
|
428
|
+
/*
|
|
429
|
+
* Descend through value-less jump-table nodes (including the
|
|
430
|
+
* single-branch encoding) inline, mirroring `decodeWithTrie`:
|
|
431
|
+
* this avoids a `determineBranch` call per level for the
|
|
432
|
+
* dominant node shape — including the root on the first write.
|
|
433
|
+
*/
|
|
434
|
+
while (
|
|
435
|
+
(current &
|
|
436
|
+
(BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) ===
|
|
437
|
+
0 &&
|
|
438
|
+
(current & BinTrieFlags.JUMP_TABLE) !== 0
|
|
439
|
+
) {
|
|
440
|
+
const char = input.charCodeAt(offset);
|
|
441
|
+
const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
442
|
+
const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
443
|
+
if (branchCount === 0) {
|
|
444
|
+
// Single branch encoded inline in the jump offset bits.
|
|
445
|
+
if (char !== jumpOffset) {
|
|
446
|
+
return this.flushAndEmitLegacyOrReject(
|
|
447
|
+
consumed,
|
|
448
|
+
excess,
|
|
449
|
+
char,
|
|
450
|
+
0,
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
treeIndex += 1;
|
|
454
|
+
} else {
|
|
455
|
+
const slot = char - jumpOffset;
|
|
456
|
+
if (slot >>> 0 >= branchCount) {
|
|
457
|
+
return this.flushAndEmitLegacyOrReject(
|
|
458
|
+
consumed,
|
|
459
|
+
excess,
|
|
460
|
+
char,
|
|
461
|
+
0,
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
const stored = decodeTree[treeIndex + 1 + slot];
|
|
465
|
+
if (stored === 0) {
|
|
466
|
+
return this.flushAndEmitLegacyOrReject(
|
|
467
|
+
consumed,
|
|
468
|
+
excess,
|
|
469
|
+
char,
|
|
470
|
+
0,
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
// End-relative: branch data ends at treeIndex+1+branchCount.
|
|
474
|
+
treeIndex = (treeIndex + branchCount + stored) & 0xff_ff;
|
|
475
|
+
}
|
|
476
|
+
current = decodeTree[treeIndex];
|
|
477
|
+
offset += 1;
|
|
478
|
+
excess += 1;
|
|
479
|
+
/*
|
|
480
|
+
* `charCodeAt` past the end returns NaN, which would alias
|
|
481
|
+
* to slot 0 after `>>> 0` — bail out explicitly.
|
|
482
|
+
*/
|
|
483
|
+
// eslint-disable-next-line unicorn/no-break-in-nested-loop
|
|
484
|
+
if (offset >= inputLength) break;
|
|
485
|
+
}
|
|
486
|
+
if (offset >= inputLength) break;
|
|
487
|
+
|
|
488
|
+
// Handle compact runs (resumable across chunks).
|
|
489
|
+
if (
|
|
490
|
+
(current &
|
|
491
|
+
(BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) ===
|
|
492
|
+
BinTrieFlags.FLAG13
|
|
493
|
+
) {
|
|
494
|
+
const runLength =
|
|
495
|
+
(current & BinTrieFlags.BRANCH_LENGTH) >> 7; /* 3..63 */
|
|
496
|
+
let { runConsumed } = this;
|
|
497
|
+
|
|
498
|
+
// If we are starting a run, check the first char.
|
|
499
|
+
if (runConsumed === 0) {
|
|
500
|
+
const char = input.charCodeAt(offset);
|
|
501
|
+
if (char !== (current & BinTrieFlags.JUMP_TABLE)) {
|
|
502
|
+
return this.flushAndEmitLegacyOrReject(
|
|
503
|
+
consumed,
|
|
504
|
+
excess,
|
|
505
|
+
char,
|
|
506
|
+
0,
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
offset += 1;
|
|
510
|
+
excess += 1;
|
|
511
|
+
runConsumed = 1;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// Check remaining characters in the run (packed two per uint16 word).
|
|
515
|
+
while (runConsumed < runLength) {
|
|
516
|
+
if (offset >= inputLength) {
|
|
517
|
+
this.treeIndex = treeIndex;
|
|
518
|
+
this.excess = excess;
|
|
519
|
+
this.consumed = consumed;
|
|
520
|
+
this.runConsumed = runConsumed;
|
|
521
|
+
return -1;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const charIndexInPacked = runConsumed - 1;
|
|
525
|
+
const packedWord =
|
|
526
|
+
decodeTree[treeIndex + 1 + (charIndexInPacked >> 1)];
|
|
527
|
+
const expectedChar =
|
|
528
|
+
(packedWord >> ((charIndexInPacked & 1) << 3)) & 0xff;
|
|
529
|
+
|
|
530
|
+
const char = input.charCodeAt(offset);
|
|
531
|
+
if (char !== expectedChar) {
|
|
532
|
+
this.runConsumed = 0;
|
|
533
|
+
return this.flushAndEmitLegacyOrReject(
|
|
534
|
+
consumed,
|
|
535
|
+
excess,
|
|
536
|
+
char,
|
|
537
|
+
0,
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
offset += 1;
|
|
541
|
+
excess += 1;
|
|
542
|
+
runConsumed += 1;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
this.runConsumed = 0;
|
|
546
|
+
treeIndex += 1 + (runLength >> 1);
|
|
547
|
+
current = decodeTree[treeIndex];
|
|
548
|
+
// Loop top handles the landed-on node (record/emit/branch).
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// Header plus out-of-line value words; 0 means no value.
|
|
553
|
+
const valueLength = current >>> 14;
|
|
554
|
+
const char = input.charCodeAt(offset);
|
|
555
|
+
|
|
556
|
+
if (valueLength !== 0) {
|
|
557
|
+
// Record a legacy match (FLAG13 clear = semicolon optional).
|
|
558
|
+
if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {
|
|
559
|
+
this.result = treeIndex;
|
|
560
|
+
consumed += excess - 1;
|
|
561
|
+
excess = 1;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/*
|
|
565
|
+
* Implicit semicolon handling: emit immediately. Covers both
|
|
566
|
+
* strict (FLAG13 set) and legacy entities — neither stores
|
|
567
|
+
* an explicit `;` branch in the trie.
|
|
568
|
+
*/
|
|
569
|
+
if (char === CharCodes.SEMI) {
|
|
570
|
+
return this.emitNamedEntityData(
|
|
571
|
+
treeIndex,
|
|
572
|
+
valueLength,
|
|
573
|
+
consumed + excess,
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/*
|
|
578
|
+
* `valueLength === 1` packs the codepoint into the header
|
|
579
|
+
* word's low 13 bits, where branch metadata also lives. Skip
|
|
580
|
+
* the branch lookup on leaves so those value bits aren't
|
|
581
|
+
* reinterpreted as branch offsets.
|
|
582
|
+
*/
|
|
583
|
+
if (valueLength === 1) {
|
|
584
|
+
return this.flushAndEmitLegacyOrReject(
|
|
585
|
+
consumed,
|
|
586
|
+
excess,
|
|
587
|
+
char,
|
|
588
|
+
valueLength,
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// Value-bearing or dictionary node: dispatch through determineBranch.
|
|
594
|
+
const next = determineBranch(
|
|
595
|
+
decodeTree,
|
|
596
|
+
current,
|
|
597
|
+
treeIndex + (valueLength || 1),
|
|
598
|
+
char,
|
|
599
|
+
);
|
|
600
|
+
|
|
601
|
+
if (next < 0) {
|
|
602
|
+
return this.flushAndEmitLegacyOrReject(
|
|
603
|
+
consumed,
|
|
604
|
+
excess,
|
|
605
|
+
char,
|
|
606
|
+
valueLength,
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
treeIndex = next;
|
|
611
|
+
current = decodeTree[treeIndex];
|
|
612
|
+
offset += 1;
|
|
613
|
+
excess += 1;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/*
|
|
617
|
+
* Chunk exhausted. Record a legacy match we may be sitting on, so a
|
|
618
|
+
* subsequent `end()` emits it, then persist the walk state.
|
|
619
|
+
*/
|
|
620
|
+
if (
|
|
621
|
+
!isStrict &&
|
|
622
|
+
current >>> 14 !== 0 &&
|
|
623
|
+
(current & BinTrieFlags.FLAG13) === 0
|
|
624
|
+
) {
|
|
625
|
+
this.result = treeIndex;
|
|
626
|
+
consumed += excess - 1;
|
|
627
|
+
excess = 1;
|
|
628
|
+
}
|
|
629
|
+
this.treeIndex = treeIndex;
|
|
630
|
+
this.excess = excess;
|
|
631
|
+
this.consumed = consumed;
|
|
632
|
+
return -1;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Emit a named entity that was not terminated with a semicolon.
|
|
637
|
+
* @returns The number of characters consumed.
|
|
638
|
+
*/
|
|
639
|
+
private emitNotTerminatedNamedEntity(): number {
|
|
640
|
+
const { result, decodeTree } = this;
|
|
641
|
+
|
|
642
|
+
const valueLength = decodeTree[result] >>> 14;
|
|
643
|
+
|
|
644
|
+
this.emitNamedEntityData(result, valueLength, this.consumed);
|
|
645
|
+
this.errors?.missingSemicolonAfterCharacterReference();
|
|
646
|
+
|
|
647
|
+
return this.consumed;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Emit a named entity.
|
|
652
|
+
* @param result The index of the entity in the decode tree.
|
|
653
|
+
* @param valueLength Encoded value length (header plus any value words).
|
|
654
|
+
* @param consumed The number of characters consumed.
|
|
655
|
+
* @returns The number of characters consumed.
|
|
656
|
+
*/
|
|
657
|
+
private emitNamedEntityData(
|
|
658
|
+
result: number,
|
|
659
|
+
valueLength: number,
|
|
660
|
+
consumed: number,
|
|
661
|
+
): number {
|
|
662
|
+
const { decodeTree } = this;
|
|
663
|
+
|
|
664
|
+
this.emitCodePoint(
|
|
665
|
+
valueLength === 1
|
|
666
|
+
? decodeTree[result] & BinTrieFlags.VALUE_MASK
|
|
667
|
+
: decodeTree[result + 1],
|
|
668
|
+
consumed,
|
|
669
|
+
);
|
|
670
|
+
if (valueLength === 3) {
|
|
671
|
+
// Emit the second UTF-16 code unit.
|
|
672
|
+
this.emitCodePoint(decodeTree[result + 2], consumed);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
return consumed;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Signal to the parser that the end of the input was reached.
|
|
680
|
+
*
|
|
681
|
+
* Remaining data will be emitted and relevant errors will be produced.
|
|
682
|
+
* @returns The number of characters consumed.
|
|
683
|
+
*/
|
|
684
|
+
end(): number {
|
|
685
|
+
switch (this.state) {
|
|
686
|
+
case EntityDecoderState.NamedEntity: {
|
|
687
|
+
// Emit a named entity if we have one.
|
|
688
|
+
return this.result !== 0 &&
|
|
689
|
+
(this.decodeMode !== DecodingMode.Attribute ||
|
|
690
|
+
this.result === this.treeIndex)
|
|
691
|
+
? this.emitNotTerminatedNamedEntity()
|
|
692
|
+
: 0;
|
|
693
|
+
}
|
|
694
|
+
// Otherwise, emit a numeric entity if we have one.
|
|
695
|
+
case EntityDecoderState.NumericDecimal: {
|
|
696
|
+
return this.emitNumericEntity(0, 2);
|
|
697
|
+
}
|
|
698
|
+
case EntityDecoderState.NumericHex: {
|
|
699
|
+
return this.emitNumericEntity(0, 3);
|
|
700
|
+
}
|
|
701
|
+
case EntityDecoderState.NumericStart: {
|
|
702
|
+
this.errors?.absenceOfDigitsInNumericCharacterReference(
|
|
703
|
+
this.consumed,
|
|
704
|
+
);
|
|
705
|
+
return 0;
|
|
706
|
+
}
|
|
707
|
+
default: {
|
|
708
|
+
// EntityStart or unknown — return 0.
|
|
709
|
+
return 0;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Determines the branch of the current node that is taken given the current
|
|
717
|
+
* character. This function is used to traverse the trie.
|
|
718
|
+
*
|
|
719
|
+
* See `BinTrieFlags` for the branch-data layouts handled here.
|
|
720
|
+
* @param decodeTree The trie.
|
|
721
|
+
* @param current The current node's header word.
|
|
722
|
+
* @param nodeIndex Index of the node's first branch-data word (the header
|
|
723
|
+
* plus any value words have been skipped by the caller).
|
|
724
|
+
* @param char The current character.
|
|
725
|
+
* @returns The index of the next node, or -1 if no branch is taken.
|
|
726
|
+
*/
|
|
727
|
+
export function determineBranch(
|
|
728
|
+
decodeTree: Uint16Array,
|
|
729
|
+
current: number,
|
|
730
|
+
nodeIndex: number,
|
|
731
|
+
char: number,
|
|
732
|
+
): number {
|
|
733
|
+
const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
734
|
+
const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
735
|
+
|
|
736
|
+
// Case 1: Single branch or jump table (jumpOffset encodes the first/only char code).
|
|
737
|
+
if (jumpOffset) {
|
|
738
|
+
if (branchCount === 0) {
|
|
739
|
+
// Single branch encoded inline in the jump offset bits.
|
|
740
|
+
return char === jumpOffset ? nodeIndex : -1;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/*
|
|
744
|
+
* Jump table: branchCount consecutive slots starting at jumpOffset.
|
|
745
|
+
* Unsigned comparison handles both < 0 and >= branchCount in one check.
|
|
746
|
+
*/
|
|
747
|
+
const slot = char - jumpOffset;
|
|
748
|
+
if (slot >>> 0 >= branchCount) return -1;
|
|
749
|
+
const stored = decodeTree[nodeIndex + slot];
|
|
750
|
+
/*
|
|
751
|
+
* 0 = empty slot (no branch); otherwise the child's offset from the
|
|
752
|
+
* end of the branch array, +1 (end-relative pointers compress
|
|
753
|
+
* better). `& 0xff_ff` mirrors the encoder's uint16 wrap for
|
|
754
|
+
* backreferences to already-encoded nodes.
|
|
755
|
+
*/
|
|
756
|
+
return stored === 0
|
|
757
|
+
? -1
|
|
758
|
+
: (nodeIndex + branchCount + stored - 1) & 0xff_ff;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/*
|
|
762
|
+
* Case 2: Packed dictionary. Linear scan — over 90% of dict nodes have
|
|
763
|
+
* <= 4 branches in the HTML trie, where the constant-factor savings
|
|
764
|
+
* dominate over binary search's asymptotic edge.
|
|
765
|
+
*/
|
|
766
|
+
if (branchCount === 0) return -1;
|
|
767
|
+
const packedKeySlots = (branchCount + 1) >> 1;
|
|
768
|
+
const branchEnd = nodeIndex + packedKeySlots + branchCount;
|
|
769
|
+
for (let index = 0; index < branchCount; index++) {
|
|
770
|
+
const packed = decodeTree[nodeIndex + (index >> 1)];
|
|
771
|
+
const key = (packed >> ((index & 1) << 3)) & 0xff;
|
|
772
|
+
if (key === char) {
|
|
773
|
+
const pointerIndex = nodeIndex + packedKeySlots + index;
|
|
774
|
+
// Pointers are relative to the end of the branch data.
|
|
775
|
+
return (branchEnd + decodeTree[pointerIndex]) & 0xff_ff;
|
|
776
|
+
}
|
|
777
|
+
// Keys are sorted; if we've passed `char`, no match is possible.
|
|
778
|
+
if (key > char) return -1;
|
|
779
|
+
}
|
|
780
|
+
return -1;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Read the decoded value from a trie node.
|
|
785
|
+
* @param decodeTree The trie.
|
|
786
|
+
* @param nodeIndex The index of the node.
|
|
787
|
+
* @param valueLength The length of the value (1, 2, or 3).
|
|
788
|
+
* @returns The decoded string.
|
|
789
|
+
*/
|
|
790
|
+
function readTrieValue(
|
|
791
|
+
decodeTree: Uint16Array,
|
|
792
|
+
nodeIndex: number,
|
|
793
|
+
valueLength: number,
|
|
794
|
+
): string {
|
|
795
|
+
if (valueLength === 1) {
|
|
796
|
+
return String.fromCharCode(
|
|
797
|
+
decodeTree[nodeIndex] & BinTrieFlags.VALUE_MASK,
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
if (valueLength === 2) {
|
|
801
|
+
return String.fromCharCode(decodeTree[nodeIndex + 1]);
|
|
802
|
+
}
|
|
803
|
+
return String.fromCharCode(
|
|
804
|
+
decodeTree[nodeIndex + 1],
|
|
805
|
+
decodeTree[nodeIndex + 2],
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Parse a numeric entity (`&#DDD;` or `&#xHHH;`).
|
|
811
|
+
*
|
|
812
|
+
* Encodes the result as `(consumed << CONSUMED_SHIFT) | codepoint` (see
|
|
813
|
+
* the packing comment at the top of the file; overlong entities spill
|
|
814
|
+
* their length into `longNumericConsumed`). Returns 0 when no digits were
|
|
815
|
+
* found.
|
|
816
|
+
*
|
|
817
|
+
* This is the sync counterpart of the streaming
|
|
818
|
+
* `EntityDecoder#stateNumericDecimal` / `#stateNumericHex`. Digit parsing
|
|
819
|
+
* matches those methods; only this packed result needs a value clamp.
|
|
820
|
+
* @param input The input string.
|
|
821
|
+
* @param numberStart Index of the `#` character.
|
|
822
|
+
* @param inputLength Cached `input.length`.
|
|
823
|
+
*/
|
|
824
|
+
function parseNumericEntity(
|
|
825
|
+
input: string,
|
|
826
|
+
numberStart: number,
|
|
827
|
+
inputLength: number,
|
|
828
|
+
): number {
|
|
829
|
+
let offset = numberStart + 1; // Skip "#"
|
|
830
|
+
let cp = 0;
|
|
831
|
+
let digitStart = offset;
|
|
832
|
+
|
|
833
|
+
/*
|
|
834
|
+
* Separate decimal and hexadecimal loops: each multiplies by a constant
|
|
835
|
+
* and runs a single digit test, instead of a per-character base check.
|
|
836
|
+
*/
|
|
837
|
+
if (
|
|
838
|
+
offset < inputLength &&
|
|
839
|
+
(input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X
|
|
840
|
+
) {
|
|
841
|
+
offset += 1;
|
|
842
|
+
digitStart = offset;
|
|
843
|
+
while (offset < inputLength) {
|
|
844
|
+
const char = input.charCodeAt(offset);
|
|
845
|
+
if (isNumber(char)) {
|
|
846
|
+
cp = cp * 16 + (char - CharCodes.ZERO);
|
|
847
|
+
} else if (isHexadecimalCharacter(char)) {
|
|
848
|
+
cp = cp * 16 + ((char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10);
|
|
849
|
+
} else {
|
|
850
|
+
break;
|
|
851
|
+
}
|
|
852
|
+
offset += 1;
|
|
853
|
+
}
|
|
854
|
+
} else {
|
|
855
|
+
while (offset < inputLength) {
|
|
856
|
+
const digit = input.charCodeAt(offset) - CharCodes.ZERO;
|
|
857
|
+
if (digit >>> 0 > 9) break;
|
|
858
|
+
cp = cp * 10 + digit;
|
|
859
|
+
offset += 1;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
if (offset === digitStart) return 0;
|
|
864
|
+
|
|
865
|
+
// Include the semicolon in consumed when present.
|
|
866
|
+
if (offset < inputLength && input.charCodeAt(offset) === CharCodes.SEMI) {
|
|
867
|
+
offset += 1;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/*
|
|
871
|
+
* Clamp out-of-range values to 0x110000 so they fit the 21-bit field
|
|
872
|
+
* and decode to U+FFFD. Lengths at or above CONSUMED_OVERFLOW use the
|
|
873
|
+
* side channel described with the packing constants.
|
|
874
|
+
*/
|
|
875
|
+
if (cp > 0x10_ff_ff) cp = 0x11_00_00;
|
|
876
|
+
let consumed = offset - numberStart;
|
|
877
|
+
if (consumed >= CONSUMED_OVERFLOW) {
|
|
878
|
+
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- deliberate side channel, see `longNumericConsumed`
|
|
879
|
+
longNumericConsumed = consumed;
|
|
880
|
+
consumed = CONSUMED_OVERFLOW;
|
|
881
|
+
}
|
|
882
|
+
return (consumed << CONSUMED_SHIFT) | cp;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Decode all entities in `input` using the HTML trie.
|
|
887
|
+
*
|
|
888
|
+
* Hard-wired to `htmlDecodeTree`: the inline root navigation below assumes
|
|
889
|
+
* the HTML root's jump-table shape, so this must not be generalized to
|
|
890
|
+
* other tries (the XML trie's dictionary root would silently match no
|
|
891
|
+
* entities — `decodeXML` has its own hand-coded fast path instead).
|
|
892
|
+
* @param input The string to decode.
|
|
893
|
+
* @param isStrict Only match semicolon-terminated entities.
|
|
894
|
+
* @param isAttribute Whether to apply attribute-specific parsing rules (disallowing certain non-semicolon terminators).
|
|
895
|
+
* @returns The decoded string.
|
|
896
|
+
*/
|
|
897
|
+
function decodeWithTrie(
|
|
898
|
+
input: string,
|
|
899
|
+
isStrict: boolean,
|
|
900
|
+
isAttribute: boolean,
|
|
901
|
+
): string {
|
|
902
|
+
const decodeTree = htmlDecodeTree;
|
|
903
|
+
// Fast path: no entities at all — return input without any allocation.
|
|
904
|
+
let offset = input.indexOf("&");
|
|
905
|
+
if (offset < 0) return input;
|
|
906
|
+
|
|
907
|
+
const inputLength = input.length;
|
|
908
|
+
/*
|
|
909
|
+
* `chunkStart` marks the start of the next pending slice. Rejected
|
|
910
|
+
* entities don't advance it, so consecutive rejections are stitched
|
|
911
|
+
* into a single `slice` once a real match (or end of input) is hit.
|
|
912
|
+
*/
|
|
913
|
+
let chunkStart = 0;
|
|
914
|
+
let result = "";
|
|
915
|
+
|
|
916
|
+
/*
|
|
917
|
+
* Root navigation fields, hoisted out of the per-entity loop. The HTML
|
|
918
|
+
* root is a multi-branch jump-table covering [A-Za-z]; see the inline
|
|
919
|
+
* first-iteration comment below.
|
|
920
|
+
*/
|
|
921
|
+
const root = decodeTree[0];
|
|
922
|
+
const rootJumpOffset = root & BinTrieFlags.JUMP_TABLE;
|
|
923
|
+
const rootBranchCount = (root & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
924
|
+
|
|
925
|
+
do {
|
|
926
|
+
const entityStart = offset + 1;
|
|
927
|
+
|
|
928
|
+
// Quick check: entity names must start with [A-Za-z], numeric with #.
|
|
929
|
+
const firstChar = input.charCodeAt(entityStart);
|
|
930
|
+
let consumed: number;
|
|
931
|
+
let value: string;
|
|
932
|
+
if (firstChar === CharCodes.NUM) {
|
|
933
|
+
const packed = parseNumericEntity(input, entityStart, inputLength);
|
|
934
|
+
consumed = unpackConsumed(packed);
|
|
935
|
+
// In strict mode, require semicolon termination.
|
|
936
|
+
if (
|
|
937
|
+
isStrict &&
|
|
938
|
+
consumed > 0 &&
|
|
939
|
+
input.charCodeAt(entityStart + consumed - 1) !== CharCodes.SEMI
|
|
940
|
+
) {
|
|
941
|
+
consumed = 0;
|
|
942
|
+
}
|
|
943
|
+
value =
|
|
944
|
+
consumed === 0
|
|
945
|
+
? ""
|
|
946
|
+
: codePointToString(packed & CODE_POINT_MASK);
|
|
947
|
+
} else if (isAlpha(firstChar)) {
|
|
948
|
+
consumed = 0;
|
|
949
|
+
value = "";
|
|
950
|
+
|
|
951
|
+
/*
|
|
952
|
+
* The generator guarantees a jump-table root. Consume the first
|
|
953
|
+
* character directly, then walk from its child.
|
|
954
|
+
*/
|
|
955
|
+
const rootSlotIndex = firstChar - rootJumpOffset;
|
|
956
|
+
let nodeIndex: number;
|
|
957
|
+
if (rootSlotIndex >>> 0 < rootBranchCount) {
|
|
958
|
+
const stored = decodeTree[1 + rootSlotIndex];
|
|
959
|
+
nodeIndex =
|
|
960
|
+
stored === 0 ? -1 : (rootBranchCount + stored) & 0xff_ff;
|
|
961
|
+
} else {
|
|
962
|
+
nodeIndex = -1;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/*
|
|
966
|
+
* Best legacy (no-semicolon) match so far, as trie coordinates.
|
|
967
|
+
* Deferring `readTrieValue` to the end avoids allocating a
|
|
968
|
+
* string for matches that longer matches supersede.
|
|
969
|
+
*/
|
|
970
|
+
let bestNodeIndex = 0;
|
|
971
|
+
let bestValueLength = 0;
|
|
972
|
+
let current = nodeIndex < 0 ? 0 : decodeTree[nodeIndex];
|
|
973
|
+
let index = entityStart + 1;
|
|
974
|
+
|
|
975
|
+
/*
|
|
976
|
+
* Walk the trie from the root child. The `trie` label lets the
|
|
977
|
+
* inner descent and compact-run loops abandon the entity (and
|
|
978
|
+
* fall through to the legacy/reject handling) directly.
|
|
979
|
+
*/
|
|
980
|
+
trie: while (index < inputLength) {
|
|
981
|
+
/*
|
|
982
|
+
* Inline value-less jump tables and single branches. A miss
|
|
983
|
+
* falls through to the recorded legacy match or rejection.
|
|
984
|
+
*/
|
|
985
|
+
while (
|
|
986
|
+
// Value-less, non-run node with a nonzero jump offset.
|
|
987
|
+
(current &
|
|
988
|
+
(BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) ===
|
|
989
|
+
0 &&
|
|
990
|
+
(current & BinTrieFlags.JUMP_TABLE) !== 0
|
|
991
|
+
) {
|
|
992
|
+
const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
993
|
+
const branchCount =
|
|
994
|
+
(current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
995
|
+
if (branchCount === 0) {
|
|
996
|
+
// Single branch encoded inline in the jump offset bits.
|
|
997
|
+
if (input.charCodeAt(index) !== jumpOffset) break trie;
|
|
998
|
+
nodeIndex += 1;
|
|
999
|
+
} else {
|
|
1000
|
+
const slot = input.charCodeAt(index) - jumpOffset;
|
|
1001
|
+
if (slot >>> 0 >= branchCount) break trie;
|
|
1002
|
+
const stored = decodeTree[nodeIndex + 1 + slot];
|
|
1003
|
+
if (stored === 0) break trie;
|
|
1004
|
+
// End-relative: branch data ends at nodeIndex+1+branchCount.
|
|
1005
|
+
nodeIndex =
|
|
1006
|
+
(nodeIndex + branchCount + stored) & 0xff_ff;
|
|
1007
|
+
}
|
|
1008
|
+
current = decodeTree[nodeIndex];
|
|
1009
|
+
index += 1;
|
|
1010
|
+
/*
|
|
1011
|
+
* `charCodeAt` past the end returns NaN, which would
|
|
1012
|
+
* alias to slot 0 after `>>> 0` — bail out explicitly.
|
|
1013
|
+
*/
|
|
1014
|
+
if (index >= inputLength) break trie;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// FLAG13 without a value marks a compact run.
|
|
1018
|
+
if (
|
|
1019
|
+
(current &
|
|
1020
|
+
(BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) ===
|
|
1021
|
+
BinTrieFlags.FLAG13
|
|
1022
|
+
) {
|
|
1023
|
+
const runLength =
|
|
1024
|
+
(current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
1025
|
+
|
|
1026
|
+
// Check first char (stored in JUMP_TABLE bits).
|
|
1027
|
+
if (
|
|
1028
|
+
input.charCodeAt(index) !==
|
|
1029
|
+
(current & BinTrieFlags.JUMP_TABLE)
|
|
1030
|
+
) {
|
|
1031
|
+
// eslint-disable-next-line unicorn/no-break-in-nested-loop
|
|
1032
|
+
break;
|
|
1033
|
+
}
|
|
1034
|
+
index += 1;
|
|
1035
|
+
|
|
1036
|
+
// Check remaining characters (packed two per uint16 word).
|
|
1037
|
+
const remaining = runLength - 1;
|
|
1038
|
+
let wordIndex = nodeIndex + 1;
|
|
1039
|
+
let charIndexInPacked = 0;
|
|
1040
|
+
|
|
1041
|
+
/*
|
|
1042
|
+
* Process pairs: read one packed word, compare low byte then high byte.
|
|
1043
|
+
* No explicit bounds check needed — charCodeAt returns NaN for OOB,
|
|
1044
|
+
* which never equals an integer, so the mismatch break fires naturally.
|
|
1045
|
+
*/
|
|
1046
|
+
for (
|
|
1047
|
+
;
|
|
1048
|
+
charIndexInPacked + 1 < remaining;
|
|
1049
|
+
charIndexInPacked += 2
|
|
1050
|
+
) {
|
|
1051
|
+
const packed = decodeTree[wordIndex];
|
|
1052
|
+
if (input.charCodeAt(index) !== (packed & 0xff))
|
|
1053
|
+
break trie;
|
|
1054
|
+
index += 1;
|
|
1055
|
+
if (input.charCodeAt(index) !== ((packed >> 8) & 0xff))
|
|
1056
|
+
break trie;
|
|
1057
|
+
index += 1;
|
|
1058
|
+
wordIndex += 1;
|
|
1059
|
+
}
|
|
1060
|
+
// Handle odd trailing char.
|
|
1061
|
+
if (charIndexInPacked < remaining) {
|
|
1062
|
+
if (
|
|
1063
|
+
input.charCodeAt(index) !==
|
|
1064
|
+
(decodeTree[wordIndex] & 0xff)
|
|
1065
|
+
)
|
|
1066
|
+
// eslint-disable-next-line unicorn/no-break-in-nested-loop
|
|
1067
|
+
break;
|
|
1068
|
+
index += 1;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
nodeIndex += 1 + (runLength >> 1);
|
|
1072
|
+
current = decodeTree[nodeIndex];
|
|
1073
|
+
// eslint-disable-next-line unicorn/no-break-in-nested-loop
|
|
1074
|
+
continue;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
// Header plus out-of-line value words; 0 means no value.
|
|
1078
|
+
const valueLength = current >>> 14;
|
|
1079
|
+
const char = input.charCodeAt(index);
|
|
1080
|
+
|
|
1081
|
+
/*
|
|
1082
|
+
* Check current node for a value before navigating.
|
|
1083
|
+
* This handles both: (a) values reached via compact runs on the
|
|
1084
|
+
* previous iteration, and (b) values at regular branch targets.
|
|
1085
|
+
*/
|
|
1086
|
+
if (valueLength !== 0) {
|
|
1087
|
+
// If char is `;`, emit immediately.
|
|
1088
|
+
if (char === CharCodes.SEMI) {
|
|
1089
|
+
consumed = index - entityStart + 1;
|
|
1090
|
+
// Inline leaves carry the value in the low 13 bits.
|
|
1091
|
+
value =
|
|
1092
|
+
valueLength === 1
|
|
1093
|
+
? String.fromCharCode(
|
|
1094
|
+
current & BinTrieFlags.VALUE_MASK,
|
|
1095
|
+
)
|
|
1096
|
+
: readTrieValue(
|
|
1097
|
+
decodeTree,
|
|
1098
|
+
nodeIndex,
|
|
1099
|
+
valueLength,
|
|
1100
|
+
);
|
|
1101
|
+
// eslint-disable-next-line unicorn/no-break-in-nested-loop
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
// Record non-terminated (legacy) match (FLAG13 clear = semicolon optional).
|
|
1106
|
+
if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {
|
|
1107
|
+
consumed = index - entityStart;
|
|
1108
|
+
bestNodeIndex = nodeIndex;
|
|
1109
|
+
bestValueLength = valueLength;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
/*
|
|
1113
|
+
* A valueLength of 1 means the value is packed inline in the header
|
|
1114
|
+
* word — these are always leaf nodes with no branches, so we can
|
|
1115
|
+
* stop walking the trie.
|
|
1116
|
+
*/
|
|
1117
|
+
// eslint-disable-next-line unicorn/no-break-in-nested-loop
|
|
1118
|
+
if (valueLength === 1) break;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
// Navigate to the next node (valueLength || 1: skip past value words, minimum 1 for header).
|
|
1122
|
+
const next = determineBranch(
|
|
1123
|
+
decodeTree,
|
|
1124
|
+
current,
|
|
1125
|
+
nodeIndex + (valueLength || 1),
|
|
1126
|
+
char,
|
|
1127
|
+
);
|
|
1128
|
+
// eslint-disable-next-line unicorn/no-break-in-nested-loop
|
|
1129
|
+
if (next < 0) break;
|
|
1130
|
+
|
|
1131
|
+
nodeIndex = next;
|
|
1132
|
+
current = decodeTree[nodeIndex];
|
|
1133
|
+
index += 1;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
/*
|
|
1137
|
+
* Post-loop: if the semicolon path didn't set value,
|
|
1138
|
+
* check for a final legacy match. The last navigation may
|
|
1139
|
+
* have landed on a legacy node whose value hasn't been
|
|
1140
|
+
* recorded yet (loop exited before the top-of-loop check
|
|
1141
|
+
* could run).
|
|
1142
|
+
*/
|
|
1143
|
+
if (value === "") {
|
|
1144
|
+
const finalVL = current >>> 14;
|
|
1145
|
+
if (
|
|
1146
|
+
finalVL !== 0 &&
|
|
1147
|
+
!isStrict &&
|
|
1148
|
+
(current & BinTrieFlags.FLAG13) === 0
|
|
1149
|
+
) {
|
|
1150
|
+
consumed = index - entityStart;
|
|
1151
|
+
bestNodeIndex = nodeIndex;
|
|
1152
|
+
bestValueLength = finalVL;
|
|
1153
|
+
}
|
|
1154
|
+
if (consumed > 0) {
|
|
1155
|
+
value = readTrieValue(
|
|
1156
|
+
decodeTree,
|
|
1157
|
+
bestNodeIndex,
|
|
1158
|
+
bestValueLength,
|
|
1159
|
+
);
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
} else {
|
|
1163
|
+
consumed = 0;
|
|
1164
|
+
value = "";
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
/*
|
|
1168
|
+
* The attribute end-char rule (HTML spec §13.2.5.73) only applies to
|
|
1169
|
+
* unterminated *named* references. Semicolon-terminated entities and
|
|
1170
|
+
* numeric entities are always accepted, matching EntityDecoder behavior.
|
|
1171
|
+
*
|
|
1172
|
+
* When `attribute` is false (the common case), short-circuit skips all
|
|
1173
|
+
* the unterminated-named checks entirely.
|
|
1174
|
+
*/
|
|
1175
|
+
if (
|
|
1176
|
+
consumed === 0 ||
|
|
1177
|
+
(isAttribute &&
|
|
1178
|
+
firstChar !== CharCodes.NUM &&
|
|
1179
|
+
input.charCodeAt(entityStart + consumed - 1) !==
|
|
1180
|
+
CharCodes.SEMI &&
|
|
1181
|
+
entityStart + consumed < inputLength &&
|
|
1182
|
+
isEntityInAttributeInvalidEnd(
|
|
1183
|
+
input.charCodeAt(entityStart + consumed),
|
|
1184
|
+
))
|
|
1185
|
+
) {
|
|
1186
|
+
// Rejected: leave `&` in the pending chunk, scan past it.
|
|
1187
|
+
offset = entityStart;
|
|
1188
|
+
} else {
|
|
1189
|
+
if (chunkStart < offset) {
|
|
1190
|
+
result += input.slice(chunkStart, offset);
|
|
1191
|
+
}
|
|
1192
|
+
result += value;
|
|
1193
|
+
offset = chunkStart = entityStart + consumed;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
/*
|
|
1197
|
+
* Adjacent entities (`&x;&y;`) are common in entity-dense input;
|
|
1198
|
+
* checking the single character at `offset` first skips the
|
|
1199
|
+
* `indexOf` call (and its per-call overhead) for that case.
|
|
1200
|
+
*/
|
|
1201
|
+
if (input.charCodeAt(offset) !== CharCodes.AMP) {
|
|
1202
|
+
offset = input.indexOf("&", offset);
|
|
1203
|
+
}
|
|
1204
|
+
} while (offset >= 0);
|
|
1205
|
+
|
|
1206
|
+
return result + input.slice(chunkStart);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Decodes an HTML string.
|
|
1211
|
+
* @param htmlString The string to decode.
|
|
1212
|
+
* @param mode The decoding mode.
|
|
1213
|
+
* @returns The decoded string.
|
|
1214
|
+
*/
|
|
1215
|
+
export function decodeHTML(
|
|
1216
|
+
htmlString: string,
|
|
1217
|
+
mode: DecodingMode = DecodingMode.Legacy,
|
|
1218
|
+
): string {
|
|
1219
|
+
return decodeWithTrie(
|
|
1220
|
+
htmlString,
|
|
1221
|
+
mode === DecodingMode.Strict,
|
|
1222
|
+
mode === DecodingMode.Attribute,
|
|
1223
|
+
);
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
/**
|
|
1227
|
+
* Decodes an HTML string in an attribute.
|
|
1228
|
+
* @param htmlAttribute The string to decode.
|
|
1229
|
+
* @returns The decoded string.
|
|
1230
|
+
*/
|
|
1231
|
+
export function decodeHTMLAttribute(htmlAttribute: string): string {
|
|
1232
|
+
return decodeWithTrie(htmlAttribute, false, true);
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* Decodes an HTML string, requiring all entities to be terminated by a semicolon.
|
|
1237
|
+
* @param htmlString The string to decode.
|
|
1238
|
+
* @returns The decoded string.
|
|
1239
|
+
*/
|
|
1240
|
+
export function decodeHTMLStrict(htmlString: string): string {
|
|
1241
|
+
return decodeWithTrie(htmlString, true, false);
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
/**
|
|
1245
|
+
* Decodes an XML string, requiring all entities to be terminated by a semicolon.
|
|
1246
|
+
*
|
|
1247
|
+
* Uses a hand-coded fast path for the 5 XML named entities (amp, lt, gt,
|
|
1248
|
+
* quot, apos) plus numeric entities, bypassing the trie entirely.
|
|
1249
|
+
* @param xmlString The string to decode.
|
|
1250
|
+
* @returns The decoded string.
|
|
1251
|
+
*/
|
|
1252
|
+
export function decodeXML(xmlString: string): string {
|
|
1253
|
+
let offset = xmlString.indexOf("&");
|
|
1254
|
+
if (offset < 0) return xmlString;
|
|
1255
|
+
|
|
1256
|
+
let lastIndex = 0;
|
|
1257
|
+
let result = "";
|
|
1258
|
+
|
|
1259
|
+
do {
|
|
1260
|
+
const start = offset + 1;
|
|
1261
|
+
let consumed = 0;
|
|
1262
|
+
let value = "";
|
|
1263
|
+
|
|
1264
|
+
const c1 = xmlString.charCodeAt(start);
|
|
1265
|
+
|
|
1266
|
+
if (c1 === CharCodes.NUM) {
|
|
1267
|
+
const packed = parseNumericEntity(
|
|
1268
|
+
xmlString,
|
|
1269
|
+
start,
|
|
1270
|
+
xmlString.length,
|
|
1271
|
+
);
|
|
1272
|
+
consumed = unpackConsumed(packed);
|
|
1273
|
+
// XML is always strict — require semicolon.
|
|
1274
|
+
if (
|
|
1275
|
+
consumed === 0 ||
|
|
1276
|
+
xmlString.charCodeAt(start + consumed - 1) !== CharCodes.SEMI
|
|
1277
|
+
) {
|
|
1278
|
+
consumed = 0;
|
|
1279
|
+
} else {
|
|
1280
|
+
const codePoint = packed & CODE_POINT_MASK;
|
|
1281
|
+
// Nonzero BMP values below the surrogate range need no replacement.
|
|
1282
|
+
value =
|
|
1283
|
+
(codePoint - 1) >>> 0 < 0xd7_ff
|
|
1284
|
+
? String.fromCharCode(codePoint)
|
|
1285
|
+
: String.fromCodePoint(replaceCodePointXML(codePoint));
|
|
1286
|
+
}
|
|
1287
|
+
} else {
|
|
1288
|
+
/* eslint-disable unicorn/no-break-in-nested-loop -- Keep XML name dispatch inline with the decode loop. */
|
|
1289
|
+
switch (c1) {
|
|
1290
|
+
// < / >
|
|
1291
|
+
case 0x6c:
|
|
1292
|
+
case 0x67: {
|
|
1293
|
+
if (
|
|
1294
|
+
xmlString.charCodeAt(start + 1) === 0x74 &&
|
|
1295
|
+
xmlString.charCodeAt(start + 2) === CharCodes.SEMI
|
|
1296
|
+
) {
|
|
1297
|
+
consumed = 3;
|
|
1298
|
+
value = c1 === 0x6c ? "<" : ">";
|
|
1299
|
+
}
|
|
1300
|
+
break;
|
|
1301
|
+
}
|
|
1302
|
+
// & / '
|
|
1303
|
+
case 0x61: {
|
|
1304
|
+
const c2 = xmlString.charCodeAt(start + 1);
|
|
1305
|
+
if (
|
|
1306
|
+
c2 === 0x6d &&
|
|
1307
|
+
xmlString.charCodeAt(start + 2) === 0x70 &&
|
|
1308
|
+
xmlString.charCodeAt(start + 3) === CharCodes.SEMI
|
|
1309
|
+
) {
|
|
1310
|
+
consumed = 4;
|
|
1311
|
+
value = "&";
|
|
1312
|
+
} else if (
|
|
1313
|
+
c2 === 0x70 &&
|
|
1314
|
+
xmlString.charCodeAt(start + 2) === 0x6f &&
|
|
1315
|
+
xmlString.charCodeAt(start + 3) === 0x73 &&
|
|
1316
|
+
xmlString.charCodeAt(start + 4) === CharCodes.SEMI
|
|
1317
|
+
) {
|
|
1318
|
+
consumed = 5;
|
|
1319
|
+
value = "'";
|
|
1320
|
+
}
|
|
1321
|
+
break;
|
|
1322
|
+
}
|
|
1323
|
+
// "
|
|
1324
|
+
case 0x71: {
|
|
1325
|
+
if (
|
|
1326
|
+
xmlString.charCodeAt(start + 1) === 0x75 &&
|
|
1327
|
+
xmlString.charCodeAt(start + 2) === 0x6f &&
|
|
1328
|
+
xmlString.charCodeAt(start + 3) === 0x74 &&
|
|
1329
|
+
xmlString.charCodeAt(start + 4) === CharCodes.SEMI
|
|
1330
|
+
) {
|
|
1331
|
+
consumed = 5;
|
|
1332
|
+
value = '"';
|
|
1333
|
+
}
|
|
1334
|
+
break;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
/* eslint-enable unicorn/no-break-in-nested-loop */
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
if (consumed > 0) {
|
|
1341
|
+
if (lastIndex < offset)
|
|
1342
|
+
result += xmlString.slice(lastIndex, offset);
|
|
1343
|
+
result += value;
|
|
1344
|
+
offset = lastIndex = start + consumed;
|
|
1345
|
+
} else {
|
|
1346
|
+
offset = start;
|
|
1347
|
+
}
|
|
1348
|
+
/*
|
|
1349
|
+
* Adjacent entities (`&x;&y;`) are common in entity-dense input;
|
|
1350
|
+
* checking the single character at `lastIndex` first skips the
|
|
1351
|
+
* `indexOf` call (and its per-call overhead) for that case.
|
|
1352
|
+
*/
|
|
1353
|
+
offset =
|
|
1354
|
+
xmlString.charCodeAt(offset) === CharCodes.AMP
|
|
1355
|
+
? offset
|
|
1356
|
+
: xmlString.indexOf("&", offset);
|
|
1357
|
+
} while (offset >= 0);
|
|
1358
|
+
|
|
1359
|
+
return result + xmlString.slice(lastIndex);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
export {
|
|
1363
|
+
replaceCodePoint,
|
|
1364
|
+
replaceCodePointXML,
|
|
1365
|
+
} from "./decode-codepoint.js";
|
|
1366
|
+
// Re-export for use by eg. htmlparser2
|
|
1367
|
+
export { htmlDecodeTree } from "./generated/decode-data-html.js";
|
|
1368
|
+
export { xmlDecodeTree } from "./generated/decode-data-xml.js";
|