Repository: cure53/DOMPurify Branch: main Commit: baed9eb46d06 Files: 83 Total size: 982.4 KB Directory structure: gitextract_rec_56zf/ ├── .babelrc ├── .editorconfig ├── .gitattributes ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE.md │ ├── PULL_REQUEST_TEMPLATE.md │ ├── dependabot.yml │ └── workflows/ │ ├── build-and-test.yml │ └── codeql-analysis.yml ├── .gitignore ├── .nvmrc ├── .prettierignore ├── .prettierrc ├── .settings/ │ └── .gitignore ├── LICENSE ├── README.md ├── SECURITY.md ├── bower.json ├── demos/ │ ├── README.md │ ├── advanced-config-demo.html │ ├── basic-demo.html │ ├── config-demo.html │ ├── hooks-demo.html │ ├── hooks-link-proxy-demo.html │ ├── hooks-mentaljs-demo.html │ ├── hooks-node-removal-demo.html │ ├── hooks-node-removal2-demo.html │ ├── hooks-proxy-demo.html │ ├── hooks-removal-demo.html │ ├── hooks-sanitize-css-demo.html │ ├── hooks-scheme-allowlist.html │ ├── hooks-target-blank-demo.html │ ├── lib/ │ │ └── Mental.js │ └── trusted-types-demo.html ├── dist/ │ ├── purify.cjs.d.ts │ ├── purify.cjs.js │ ├── purify.es.d.mts │ ├── purify.es.mjs │ └── purify.js ├── package.json ├── rollup.config.js ├── scripts/ │ ├── commit-amend-build.sh │ └── fix-types.js ├── src/ │ ├── attrs.ts │ ├── config.ts │ ├── license_header │ ├── purify.ts │ ├── regexp.ts │ ├── tags.ts │ └── utils.ts ├── test/ │ ├── bootstrap-test-suite.js │ ├── config/ │ │ └── setup.js │ ├── fixtures/ │ │ └── expect.mjs │ ├── jsdom-node-runner.js │ ├── jsdom-node.js │ ├── karma.conf.js │ ├── karma.custom-launchers.config.js │ ├── purify.min.spec.js │ ├── purify.spec.js │ └── test-suite.js ├── tsconfig.json ├── typescript/ │ ├── commonjs/ │ │ ├── index.ts │ │ └── tsconfig.json │ ├── commonjs-with-no-types/ │ │ ├── index.ts │ │ ├── tsconfig.json │ │ └── types/ │ │ └── readme.md │ ├── commonjs-with-specific-types/ │ │ ├── index.ts │ │ └── tsconfig.json │ ├── esm/ │ │ ├── index.ts │ │ ├── package.json │ │ └── tsconfig.json │ ├── esm-with-no-types/ │ │ ├── index.ts │ │ ├── package.json │ │ ├── tsconfig.json │ │ └── types/ │ │ └── readme.md │ ├── esm-with-specific-types/ │ │ ├── index.ts │ │ ├── package.json │ │ └── tsconfig.json │ ├── nodenext/ │ │ ├── index.ts │ │ └── tsconfig.json │ ├── package.json │ └── verify.js └── website/ └── index.html ================================================ FILE CONTENTS ================================================ ================================================ FILE: .babelrc ================================================ { "presets": [ [ "@babel/preset-env", { "targets": { "chrome": 51, "firefox": 53, "opera": 38, "safari": 11, "edge": 51 }, "modules": false } ] ] } ================================================ FILE: .editorconfig ================================================ # http://EditorConfig.org root = true [*] charset = utf-8 end_of_line = lf indent_size = 2 indent_style = space insert_final_newline = true trim_trailing_whitespace = true ================================================ FILE: .gitattributes ================================================ * text eol=lf ================================================ FILE: .github/FUNDING.yml ================================================ github: cure53 ================================================ FILE: .github/ISSUE_TEMPLATE.md ================================================ > This issue proposes a [bug, feature] which... ### Background & Context Please provide some more detailed information about the general background and context of this issue and delete non applicable sections below. ### Bug #### Input Some HTML which is thrown at DOMPurify. #### Given output The output given by DOMPurify. #### Expected output The expected output. ### Feature Briefly outline the proposed feature, its value and a potentially proposed implementation from a high level. ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ ## Summary ## Background & Context ## Tasks - xxxx - xxxx - xxxx ## Dependencies - [x] Resolved dependency - [ ] Open dependency ================================================ FILE: .github/dependabot.yml ================================================ version: 2 updates: - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" ================================================ FILE: .github/workflows/build-and-test.yml ================================================ name: Build and Test # The event triggers are configured as following: # - on `main` -> trigger the workflow on every push # - on any pull request -> trigger the workflow # This is to avoid running the workflow twice on pull requests. on: push: branches: - main - 3.x - 2.x pull_request: jobs: install: runs-on: ubuntu-latest strategy: matrix: node-version: [20.x, 22.x, 24.x, 25.x] steps: - name: Checkout uses: actions/checkout@v6 - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: 'npm' - name: Install Dependencies run: npm ci - name: Build run: npm run build - name: Lint run: npm run lint - name: Test uses: GabrielBB/xvfb-action@v1.7 with: run: npm run test:ci env: TEST_BROWSERSTACK: ${{ startsWith(matrix.node-version, '24') }} TEST_PROBE_ONLY: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/2.x' }} BS_USERNAME: ${{ secrets.BS_USERNAME }} BS_ACCESSKEY: ${{ secrets.BS_ACCESSKEY }} - name: Verify TypeScript run: npm run verify-typescript ================================================ FILE: .github/workflows/codeql-analysis.yml ================================================ name: "CodeQL" on: push: branches: [main] pull_request: # The branches below must be a subset of the branches above branches: [main] schedule: - cron: '0 19 * * 4' jobs: analyze: name: Analyze runs-on: ubuntu-latest strategy: fail-fast: false matrix: # Override automatic language detection by changing the below list # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] language: ['javascript'] # Learn more... # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection steps: - name: Checkout repository uses: actions/checkout@v6 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. fetch-depth: 2 # If this run was triggered by a pull request event, then checkout # the head of the pull request instead of the merge commit. - run: git checkout HEAD^2 if: ${{ github.event_name == 'pull_request' }} # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v4 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines # and modify them (or add more) to build your code if your project # uses a compiled language #- run: | # make bootstrap # make release - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v4 ================================================ FILE: .gitignore ================================================ .project node_modules bower_components npm-debug.log .vscode yarn-error.log nbproject/private/private.properties nbproject/project.properties nbproject/private/private.xml ================================================ FILE: .nvmrc ================================================ lts/* ================================================ FILE: .prettierignore ================================================ ================================================ FILE: .prettierrc ================================================ { "trailingComma": "es5", "singleQuote": true } ================================================ FILE: .settings/.gitignore ================================================ /.jsdtscope /org.eclipse.ltk.core.refactoring.prefs /org.eclipse.wst.common.project.facet.core.xml /org.eclipse.wst.jsdt.ui.superType.container /org.eclipse.wst.jsdt.ui.superType.name ================================================ FILE: LICENSE ================================================ DOMPurify Copyright 2025 Dr.-Ing. Mario Heiderich, Cure53 DOMPurify is free software; you can redistribute it and/or modify it under the terms of either: a) the Apache License Version 2.0, or b) the Mozilla Public License Version 2.0 ----------------------------------------------------------------------------- Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ----------------------------------------------------------------------------- Mozilla Public License, version 2.0 1. Definitions 1.1. “Contributor” means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. “Contributor Version” means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution. 1.3. “Contribution” means Covered Software of a particular Contributor. 1.4. “Covered Software” means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. “Incompatible With Secondary Licenses” means a. that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or b. that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. “Executable Form” means any form of the work other than Source Code Form. 1.7. “Larger Work” means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. “License” means this document. 1.9. “Licensable” means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. “Modifications” means any of the following: a. any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or b. any new file in Source Code Form that contains any Covered Software. 1.11. “Patent Claims” of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. “Secondary License” means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. “Source Code Form” means the form of the work preferred for making modifications. 1.14. “You” (or “Your”) means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: a. under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and b. under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: a. for any code that a Contributor has removed from Covered Software; or b. for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or c. under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: a. such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and b. You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. 6. Disclaimer of Warranty Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer. 7. Limitation of Liability Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You. 8. Litigation Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims. 9. Miscellaneous This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - “Incompatible With Secondary Licenses” Notice This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0. ================================================ FILE: README.md ================================================ # DOMPurify [![npm](https://badge.fury.io/js/dompurify.svg)](http://badge.fury.io/js/dompurify) ![Tests](https://github.com/cure53/DOMPurify/workflows/Build%20and%20Test/badge.svg) [![Downloads](https://img.shields.io/npm/dm/dompurify.svg)](https://www.npmjs.com/package/dompurify) ![npm package minimized gzipped size (select exports)](https://img.shields.io/bundlejs/size/dompurify?color=%233C1&label=gzip) [![dependents](https://badgen.net/github/dependents-repo/cure53/dompurify?color=green&label=dependents)](https://github.com/cure53/DOMPurify/network/dependents) [![Cloudback](https://app.cloudback.it/badge/cure53/DOMPurify)](https://cloudback.it) DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. It's also very simple to use and get started with. DOMPurify was [started in February 2014](https://github.com/cure53/DOMPurify/commit/a630922616927373485e0e787ab19e73e3691b2b) and, meanwhile, has reached version **v3.3.3**. DOMPurify runs as JavaScript and works in all modern browsers (Safari (10+), Opera (15+), Edge, Firefox and Chrome - as well as almost anything else using Blink, Gecko or WebKit). It doesn't break on MSIE or other legacy browsers. It simply does nothing. **Note that [DOMPurify v2.5.9](https://github.com/cure53/DOMPurify/releases/tag/2.5.9) is the latest version supporting MSIE. For important security updates compatible with MSIE, please use the [2.x branch](https://github.com/cure53/DOMPurify/tree/2.x).** Our automated tests cover [28 different browsers](https://github.com/cure53/DOMPurify/blob/main/test/karma.custom-launchers.config.js#L5) right now, more to come. We also cover Node.js v20.x, v22.x, 24.x and v25.x, running DOMPurify on [jsdom](https://github.com/jsdom/jsdom). Older Node versions are known to work as well, but hey... no guarantees. DOMPurify is written by security people who have vast background in web attacks and XSS. Fear not. For more details please also read about our [Security Goals & Threat Model](https://github.com/cure53/DOMPurify/wiki/Security-Goals-&-Threat-Model). Please, read it. Like, really. ## What does it do? DOMPurify sanitizes HTML and prevents XSS attacks. You can feed DOMPurify with string full of dirty HTML and it will return a string (unless configured otherwise) with clean HTML. DOMPurify will strip out everything that contains dangerous HTML and thereby prevent XSS attacks and other nastiness. It's also damn bloody fast. We use the technologies the browser provides and turn them into an XSS filter. The faster your browser, the faster DOMPurify will be. ## How do I use it? It's easy. Just include DOMPurify on your website. ### Using the unminified version (source-map available) ```html ``` ### Using the minified and tested production version (source-map available) ```html ``` Afterwards you can sanitize strings by executing the following code: ```js const clean = DOMPurify.sanitize(dirty); ``` Or maybe this, if you love working with Angular or alike: ```js import DOMPurify from 'dompurify'; const clean = DOMPurify.sanitize('hello there'); ``` The resulting HTML can be written into a DOM element using `innerHTML` or the DOM using `document.write()`. That is fully up to you. Note that by default, we permit HTML, SVG **and** MathML. If you only need HTML, which might be a very common use-case, you can easily set that up as well: ```js const clean = DOMPurify.sanitize(dirty, { USE_PROFILES: { html: true } }); ``` ### Is there any foot-gun potential? Well, please note, if you _first_ sanitize HTML and then modify it _afterwards_, you might easily **void the effects of sanitization**. If you feed the sanitized markup to another library _after_ sanitization, please be certain that the library doesn't mess around with the HTML on its own. ### Okay, makes sense, let's move on After sanitizing your markup, you can also have a look at the property `DOMPurify.removed` and find out, what elements and attributes were thrown out. Please **do not use** this property for making any security critical decisions. This is just a little helper for curious minds. ### Running DOMPurify on the server DOMPurify technically also works server-side with Node.js. Our support strives to follow the [Node.js release cycle](https://nodejs.org/en/about/previous-releases). Running DOMPurify on the server requires a DOM to be present, which is probably no surprise. Usually, [jsdom](https://github.com/jsdom/jsdom) is the tool of choice and we **strongly recommend** to use the latest version of _jsdom_. Why? Because older versions of _jsdom_ are known to be buggy in ways that result in XSS _even if_ DOMPurify does everything 100% correctly. There are **known attack vectors** in, e.g. _jsdom v19.0.0_ that are fixed in _jsdom v20.0.0_ - and we really recommend to keep _jsdom_ up to date because of that. Please also be aware that tools like [happy-dom](https://github.com/capricorn86/happy-dom) exist but **are not considered safe** at this point. Combining DOMPurify with _happy-dom_ is currently not recommended and will likely lead to XSS. Other than that, you are fine to use DOMPurify on the server. Probably. This really depends on _jsdom_ or whatever DOM you utilize server-side. If you can live with that, this is how you get it to work: ```bash npm install dompurify npm install jsdom ``` For _jsdom_ (please use an up-to-date version), this should do the trick: ```js const createDOMPurify = require('dompurify'); const { JSDOM } = require('jsdom'); const window = new JSDOM('').window; const DOMPurify = createDOMPurify(window); const clean = DOMPurify.sanitize('hello there'); ``` Or even this, if you prefer working with imports: ```js import { JSDOM } from 'jsdom'; import DOMPurify from 'dompurify'; const window = new JSDOM('').window; const purify = DOMPurify(window); const clean = purify.sanitize('hello there'); ``` If you have problems making it work in your specific setup, consider looking at the amazing [isomorphic-dompurify](https://github.com/kkomelin/isomorphic-dompurify) project which solves lots of problems people might run into. ```bash npm install isomorphic-dompurify ``` ```js import DOMPurify from 'isomorphic-dompurify'; const clean = DOMPurify.sanitize('hello'); ``` ## Is there a demo? Of course there is a demo! [Play with DOMPurify](https://cure53.de/purify) ## What if I find a _security_ bug? First of all, please immediately contact us via [email](mailto:mario@cure53.de) so we can work on a fix. [PGP key](https://keyserver.ubuntu.com/pks/lookup?op=vindex&search=0xC26C858090F70ADA) Also, you probably qualify for a bug bounty! The fine folks over at [Fastmail](https://www.fastmail.com/) use DOMPurify for their services and added our library to their bug bounty scope. So, if you find a way to bypass or weaken DOMPurify, please also have a look at their website and the [bug bounty info](https://www.fastmail.com/about/bugbounty/). ## Some purification samples please? How does purified markup look like? Well, [the demo](https://cure53.de/purify) shows it for a big bunch of nasty elements. But let's also show some smaller examples! ```js DOMPurify.sanitize(''); // becomes DOMPurify.sanitize(''); // becomes DOMPurify.sanitize('

abc
goodbye

not me!

`; // Specify a configuration directive const config = { ALLOWED_TAGS: ['p', '#text'], // only

and text nodes KEEP_CONTENT: false, // remove content from non-allow-listed nodes too ADD_ATTR: ['kitty-litter'], // permit kitty-litter attributes ADD_TAGS: ['ying', 'yang'], // permit additional custom tags RETURN_DOM: true // return a document object instead of a string }; // Clean HTML string and write into our DIV const clean = DOMPurify.sanitize(dirty, config); // Grab innerHTML from returned clean body node document.getElementById('sanitized').innerHTML = clean.innerHTML; ================================================ FILE: demos/basic-demo.html ================================================

================================================ FILE: demos/config-demo.html ================================================
================================================ FILE: demos/hooks-demo.html ================================================
================================================ FILE: demos/hooks-link-proxy-demo.html ================================================
================================================ FILE: demos/hooks-mentaljs-demo.html ================================================
================================================ FILE: demos/hooks-node-removal-demo.html ================================================
================================================ FILE: demos/hooks-node-removal2-demo.html ================================================


        
        
    



================================================
FILE: demos/hooks-proxy-demo.html
================================================


    
        
    
    
        
        
================================================ FILE: demos/hooks-removal-demo.html ================================================
================================================ FILE: demos/hooks-sanitize-css-demo.html ================================================
================================================ FILE: demos/hooks-scheme-allowlist.html ================================================
================================================ FILE: demos/hooks-target-blank-demo.html ================================================
================================================ FILE: demos/lib/Mental.js ================================================ (function(exports) { var rulesLookup = { 0 : 'ArrayComma', 1 : 'ArrayOpen', 2 : 'ArrayClose', 3 : 'AccessorOpen', 4 : 'AccessorClose', 5 : 'Addition', 6 : 'AdditionAssignment', 7 : 'AssignmentDivide', 8 : 'AndAssignment', 9 : 'BlockStatementCurlyOpen', 10 : 'BlockStatementCurlyClose', 11 : 'BitwiseNot', 12 : 'BitwiseOr', 13 : 'BitwiseAnd', 14 : 'Break', 15 : 'Case', 16 : 'Default', 17 : 'Delete', 18 : 'Do', 19 : 'DoStatementCurlyOpen', 20 : 'DoStatementCurlyClose', 21 : 'DivideOperator', 22 : 'CatchStatement', 23 : 'CatchStatementParenOpen', 24 : 'CatchStatementParenClose', 25 : 'CatchStatementIdentifier', 26 : 'CatchStatementCurlyOpen', 27 : 'CatchStatementCurlyClose', 28 : 'Comma', 29 : 'Continue', 30 : 'EqualAssignment', 31 : 'Equal', 32 : 'Else', 33 : 'ElseCurlyOpen', 34 : 'ElseCurlyClose', 35 : 'EndStatement', 36 : 'False', 37 : 'FinallyStatement', 38 : 'FinallyStatementCurlyOpen', 39 : 'FinallyStatementCurlyClose', 40 : 'ForStatement', 41 : 'ForStatementParenOpen', 42 : 'ForStatementParenClose', 43 : 'ForStatementCurlyOpen', 44 : 'ForStatementCurlyClose', 45 : 'ForSemi', 46 : 'FunctionCallOpen', 47 : 'FunctionCallClose', 48 : 'FunctionArgumentIdentifier', 49 : 'FunctionArgumentComma', 50 : 'FunctionIdentifier', 51 : 'FunctionParenOpen', 52 : 'FunctionExpression', 53 : 'FunctionExpressionIdentifier', 54 : 'FunctionExpressionParenOpen', 55 : 'FunctionExpressionArgumentIdentifier', 56 : 'FunctionExpressionArgumentComma', 57 : 'FunctionParenClose', 58 : 'FunctionExpressionParenClose', 59 : 'FunctionExpressionCurlyOpen', 60 : 'FunctionStatement', 61 : 'FunctionStatementCurlyOpen', 62 : 'FunctionStatementCurlyClose', 63 : 'FunctionExpressionCurlyClose', 64 : 'GreaterThan', 65 : 'GreaterThanEqual', 66 : 'IdentifierDot', 67 : 'Identifier', 68 : 'IfStatement', 69 : 'IfStatementParenOpen', 70 : 'IfStatementParenClose', 71 : 'IfStatementCurlyOpen', 72 : 'IfStatementCurlyClose', 73 : 'In', 74 : 'Infinity', 75 : 'InstanceOf', 76 : 'LabelColon', 77 : 'LessThan', 78 : 'LessThanEqual', 79 : 'LeftShift', 80 : 'LeftShiftAssignment', 81 : 'LogicalOr', 82 : 'LogicalAnd', 83 : 'NaN', 84 : 'New', 85 : 'Number', 86 : 'Null', 87 : 'NotEqual', 88 : 'Not', 89 : 'Nothing', 90 : 'Minus', 91 : 'MinusAssignment', 92 : 'Modulus', 93 : 'ModulusAssignment', 94 : 'Multiply', 95 : 'MultiplyAssignment', 96 : 'ObjectLiteralCurlyOpen', 97 : 'ObjectLiteralCurlyClose', 98 : 'ObjectLiteralIdentifier', 99 : 'ObjectLiteralColon', 100 : 'ObjectLiteralComma', 101 : 'ObjectLiteralIdentifierNumber', 102 : 'ObjectLiteralIdentifierString', 103 : 'OrAssignment', 104 : 'ParenExpressionOpen', 105 : 'ParenExpressionComma', 106 : 'ParenExpressionClose', 107 : 'PostfixIncrement', 108 : 'PostfixDeincrement', 109 : 'PrefixDeincrement', 110 : 'PrefixIncrement', 111 : 'Return', 112 : 'RegExp', 113 : 'RightShift', 114 : 'RightShiftAssignment', 115 : 'String', 116 : 'StrictEqual', 117 : 'StrictNotEqual', 118 : 'SwitchStatement', 119 : 'SwitchStatementParenOpen', 120 : 'SwitchStatementParenClose', 121 : 'SwitchStatementCurlyOpen', 122 : 'SwitchStatementCurlyClose', 123 : 'SwitchColon', 124 : 'This', 125 : 'TernaryQuestionMark', 126 : 'TernaryColon', 127 : 'TryStatement', 128 : 'TryStatementCurlyOpen', 129 : 'TryStatementCurlyClose', 130 : 'True', 131 : 'Throw', 132 : 'TypeOf', 133 : 'UnaryPlus', 134 : 'UnaryMinus', 135 : 'Undefined', 136 : 'Var', 137 : 'VarIdentifier', 138 : 'VarComma', 139 : 'Void', 140 : 'WithStatement', 141 : 'WithStatementParenOpen', 142 : 'WithStatementParenClose', 143 : 'WithStatementCurlyOpen', 144 : 'WithStatementCurlyClose', 145 : 'WhileStatement', 146 : 'WhileStatementParenOpen', 147 : 'WhileStatementParenClose', 148 : 'WhileStatementCurlyOpen', 149 : 'WhileStatementCurlyClose', 150 : 'Xor', 151 : 'XorAssignment', 152 : 'ZeroRightShift', 153 : 'ZeroRightShiftAssignment' }, rules = { 0 : {//ArrayComma 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 2 : 1, //ArrayClose 3 : 1, //AccessorOpen 4 : 1, //AccessorClose 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 28 : 1, //Comma 29 : 1, //Continue 36 : 1, //False 41 : 1, //ForStatementParenOpen 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 69 : 1, //IfStatementParenOpen 74 : 1, //Infinity 83 : 1, //NaN 84 : 1, //New 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 99 : 1, //ObjectLiteralColon 104 : 1, //ParenExpressionOpen 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 119 : 1, //SwitchStatementParenOpen 124 : 1, //This 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 130 : 1, //True 131 : 1, //Throw 132 : 1, //TypeOf 135 : 1, //Undefined 137 : 1, //VarIdentifier 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 146 : 1 //WhileStatementParenOpen }, 1 : {//ArrayOpen 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 2 : {//ArrayClose 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 3 : {//AccessorOpen 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 4 : {//AccessorClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 5 : {//Addition 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 6 : {//AdditionAssignment 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 7 : {//AssignmentDivide 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 8 : {//AndAssignment 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 9 : {//BlockStatementCurlyOpen 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 10 : {//BlockStatementCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 11 : {//BitwiseNot 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 12 : {//BitwiseOr 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 13 : {//BitwiseAnd 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 14 : {//Break 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 15 : {//Case 35 : 1, //EndStatement 121 : 1, //SwitchStatementCurlyOpen 123 : 1 //SwitchColon }, 16 : {//Default 35 : 1, //EndStatement 121 : 1, //SwitchStatementCurlyOpen 123 : 1 //SwitchColon }, 17 : {//Delete 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 18 : {//Do 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 19 : {//DoStatementCurlyOpen 18 : 1 //Do }, 20 : {//DoStatementCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 21 : {//DivideOperator 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 22 : {//CatchStatement 129 : 1 //TryStatementCurlyClose }, 23 : {//CatchStatementParenOpen 22 : 1 //CatchStatement }, 24 : {//CatchStatementParenClose 25 : 1 //CatchStatementIdentifier }, 25 : {//CatchStatementIdentifier 23 : 1 //CatchStatementParenOpen }, 26 : {//CatchStatementCurlyOpen 24 : 1 //CatchStatementParenClose }, 27 : {//CatchStatementCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 28 : {//Comma 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 29 : {//Continue 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 30 : {//EqualAssignment 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 31 : {//Equal 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 32 : {//Else 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 33 : {//ElseCurlyOpen 32 : 1 //Else }, 34 : {//ElseCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 35 : {//EndStatement 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 36 : {//False 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 37 : {//FinallyStatement 27 : 1, //CatchStatementCurlyClose 129 : 1 //TryStatementCurlyClose }, 38 : {//FinallyStatementCurlyOpen 37 : 1 //FinallyStatement }, 39 : {//FinallyStatementCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 40 : {//ForStatement 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 41 : {//ForStatementParenOpen 40 : 1 //ForStatement }, 42 : {//ForStatementParenClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 14 : 1, //Break 29 : 1, //Continue 36 : 1, //False 45 : 1, //ForSemi 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 43 : {//ForStatementCurlyOpen 42 : 1 //ForStatementParenClose }, 44 : {//ForStatementCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 45 : {//ForSemi 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 41 : 1, //ForStatementParenOpen 45 : 1, //ForSemi 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 46 : {//FunctionCallOpen 4 : 1, //AccessorClose 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 106 : 1, //ParenExpressionClose 124 : 1 //This }, 47 : {//FunctionCallClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 46 : 1, //FunctionCallOpen 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 48 : {//FunctionArgumentIdentifier 49 : 1, //FunctionArgumentComma 51 : 1 //FunctionParenOpen }, 49 : {//FunctionArgumentComma 48 : 1 //FunctionArgumentIdentifier }, 50 : {//FunctionIdentifier 60 : 1 //FunctionStatement }, 51 : {//FunctionParenOpen 50 : 1 //FunctionIdentifier }, 52 : {//FunctionExpression 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 21 : 1, //DivideOperator 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 41 : 1, //ForStatementParenOpen 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 73 : 1, //In 75 : 1, //InstanceOf 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 146 : 1, //WhileStatementParenOpen 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 53 : {//FunctionExpressionIdentifier 52 : 1 //FunctionExpression }, 54 : {//FunctionExpressionParenOpen 52 : 1, //FunctionExpression 53 : 1 //FunctionExpressionIdentifier }, 55 : {//FunctionExpressionArgumentIdentifier 54 : 1, //FunctionExpressionParenOpen 56 : 1 //FunctionExpressionArgumentComma }, 56 : {//FunctionExpressionArgumentComma 55 : 1 //FunctionExpressionArgumentIdentifier }, 57 : {//FunctionParenClose 48 : 1, //FunctionArgumentIdentifier 51 : 1 //FunctionParenOpen }, 58 : {//FunctionExpressionParenClose 54 : 1, //FunctionExpressionParenOpen 55 : 1 //FunctionExpressionArgumentIdentifier }, 59 : {//FunctionExpressionCurlyOpen 58 : 1 //FunctionExpressionParenClose }, 60 : {//FunctionStatement 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 61 : {//FunctionStatementCurlyOpen 57 : 1 //FunctionParenClose }, 62 : {//FunctionStatementCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 63 : {//FunctionExpressionCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 64 : {//GreaterThan 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 65 : {//GreaterThanEqual 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 66 : {//IdentifierDot 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 67 : {//Identifier 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 66 : 1, //IdentifierDot 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 68 : {//IfStatement 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 69 : {//IfStatementParenOpen 68 : 1 //IfStatement }, 70 : {//IfStatementParenClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 71 : {//IfStatementCurlyOpen 70 : 1 //IfStatementParenClose }, 72 : {//IfStatementCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 73 : {//In 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 74 : {//Infinity 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 75 : {//InstanceOf 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 76 : {//LabelColon 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 77 : {//LessThan 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 78 : {//LessThanEqual 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 79 : {//LeftShift 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 80 : {//LeftShiftAssignment 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 81 : {//LogicalOr 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 82 : {//LogicalAnd 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 83 : {//NaN 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 84 : {//New 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 85 : {//Number 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 86 : {//Null 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 87 : {//NotEqual 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 88 : {//Not 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 89 : {//Nothing }, 90 : {//Minus 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 91 : {//MinusAssignment 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 92 : {//Modulus 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 93 : {//ModulusAssignment 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 94 : {//Multiply 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 95 : {//MultiplyAssignment 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 96 : {//ObjectLiteralCurlyOpen 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 21 : 1, //DivideOperator 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 41 : 1, //ForStatementParenOpen 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 73 : 1, //In 75 : 1, //InstanceOf 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 146 : 1, //WhileStatementParenOpen 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 97 : {//ObjectLiteralCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 96 : 1, //ObjectLiteralCurlyOpen 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 98 : {//ObjectLiteralIdentifier 96 : 1, //ObjectLiteralCurlyOpen 100 : 1 //ObjectLiteralComma }, 99 : {//ObjectLiteralColon 98 : 1, //ObjectLiteralIdentifier 101 : 1, //ObjectLiteralIdentifierNumber 102 : 1 //ObjectLiteralIdentifierString }, 100 : {//ObjectLiteralComma 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 101 : {//ObjectLiteralIdentifierNumber 96 : 1, //ObjectLiteralCurlyOpen 100 : 1 //ObjectLiteralComma }, 102 : {//ObjectLiteralIdentifierString 96 : 1, //ObjectLiteralCurlyOpen 100 : 1 //ObjectLiteralComma }, 103 : {//OrAssignment 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 104 : {//ParenExpressionOpen 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 105 : {//ParenExpressionComma 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 106 : {//ParenExpressionClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 107 : {//PostfixIncrement 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 108 : {//PostfixDeincrement 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 109 : {//PrefixDeincrement 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 110 : {//PrefixIncrement 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 111 : {//Return 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 112 : {//RegExp 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 113 : {//RightShift 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 114 : {//RightShiftAssignment 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 115 : {//String 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 116 : {//StrictEqual 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 117 : {//StrictNotEqual 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 118 : {//SwitchStatement 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 119 : {//SwitchStatementParenOpen 118 : 1 //SwitchStatement }, 120 : {//SwitchStatementParenClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 121 : {//SwitchStatementCurlyOpen 120 : 1 //SwitchStatementParenClose }, 122 : {//SwitchStatementCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 123 : {//SwitchColon 2 : 1, //ArrayClose 4 : 1, //AccessorClose 16 : 1, //Default 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 124 : {//This 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 125 : {//TernaryQuestionMark 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 126 : {//TernaryColon 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 127 : {//TryStatement 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 128 : {//TryStatementCurlyOpen 127 : 1 //TryStatement }, 129 : {//TryStatementCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 130 : {//True 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 131 : {//Throw 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 84 : 1, //New 89 : 1, //Nothing 99 : 1, //ObjectLiteralColon 104 : 1, //ParenExpressionOpen 111 : 1, //Return 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 132 : {//TypeOf 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 133 : {//UnaryPlus 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 134 : {//UnaryMinus 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 135 : {//Undefined 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 11 : 1, //BitwiseNot 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 88 : 1, //Not 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 109 : 1, //PrefixDeincrement 110 : 1, //PrefixIncrement 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 133 : 1, //UnaryPlus 134 : 1, //UnaryMinus 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 136 : {//Var 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 84 : 1, //New 89 : 1, //Nothing 99 : 1, //ObjectLiteralColon 104 : 1, //ParenExpressionOpen 111 : 1, //Return 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 137 : {//VarIdentifier 136 : 1, //Var 138 : 1 //VarComma }, 138 : {//VarComma 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 139 : {//Void 0 : 1, //ArrayComma 1 : 1, //ArrayOpen 3 : 1, //AccessorOpen 5 : 1, //Addition 6 : 1, //AdditionAssignment 7 : 1, //AssignmentDivide 8 : 1, //AndAssignment 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 12 : 1, //BitwiseOr 13 : 1, //BitwiseAnd 14 : 1, //Break 15 : 1, //Case 17 : 1, //Delete 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 21 : 1, //DivideOperator 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 28 : 1, //Comma 29 : 1, //Continue 30 : 1, //EqualAssignment 31 : 1, //Equal 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 41 : 1, //ForStatementParenOpen 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 45 : 1, //ForSemi 46 : 1, //FunctionCallOpen 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 64 : 1, //GreaterThan 65 : 1, //GreaterThanEqual 69 : 1, //IfStatementParenOpen 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 73 : 1, //In 75 : 1, //InstanceOf 76 : 1, //LabelColon 77 : 1, //LessThan 78 : 1, //LessThanEqual 79 : 1, //LeftShift 80 : 1, //LeftShiftAssignment 81 : 1, //LogicalOr 82 : 1, //LogicalAnd 84 : 1, //New 87 : 1, //NotEqual 89 : 1, //Nothing 90 : 1, //Minus 91 : 1, //MinusAssignment 92 : 1, //Modulus 93 : 1, //ModulusAssignment 94 : 1, //Multiply 95 : 1, //MultiplyAssignment 99 : 1, //ObjectLiteralColon 103 : 1, //OrAssignment 104 : 1, //ParenExpressionOpen 111 : 1, //Return 113 : 1, //RightShift 114 : 1, //RightShiftAssignment 116 : 1, //StrictEqual 117 : 1, //StrictNotEqual 119 : 1, //SwitchStatementParenOpen 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 125 : 1, //TernaryQuestionMark 126 : 1, //TernaryColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 131 : 1, //Throw 132 : 1, //TypeOf 138 : 1, //VarComma 139 : 1, //Void 141 : 1, //WithStatementParenOpen 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 146 : 1, //WhileStatementParenOpen 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1, //WhileStatementCurlyClose 150 : 1, //Xor 151 : 1, //XorAssignment 152 : 1, //ZeroRightShift 153 : 1 //ZeroRightShiftAssignment }, 140 : {//WithStatement 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 141 : {//WithStatementParenOpen 140 : 1 //WithStatement }, 142 : {//WithStatementParenClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 143 : {//WithStatementCurlyOpen 142 : 1 //WithStatementParenClose }, 144 : {//WithStatementCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 145 : {//WhileStatement 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 76 : 1, //LabelColon 89 : 1, //Nothing 111 : 1, //Return 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 146 : {//WhileStatementParenOpen 145 : 1 //WhileStatement }, 147 : {//WhileStatementParenClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 148 : {//WhileStatementCurlyOpen 147 : 1 //WhileStatementParenClose }, 149 : {//WhileStatementCurlyClose 2 : 1, //ArrayClose 4 : 1, //AccessorClose 9 : 1, //BlockStatementCurlyOpen 10 : 1, //BlockStatementCurlyClose 14 : 1, //Break 18 : 1, //Do 19 : 1, //DoStatementCurlyOpen 20 : 1, //DoStatementCurlyClose 26 : 1, //CatchStatementCurlyOpen 27 : 1, //CatchStatementCurlyClose 29 : 1, //Continue 32 : 1, //Else 33 : 1, //ElseCurlyOpen 34 : 1, //ElseCurlyClose 35 : 1, //EndStatement 36 : 1, //False 38 : 1, //FinallyStatementCurlyOpen 39 : 1, //FinallyStatementCurlyClose 42 : 1, //ForStatementParenClose 43 : 1, //ForStatementCurlyOpen 44 : 1, //ForStatementCurlyClose 47 : 1, //FunctionCallClose 59 : 1, //FunctionExpressionCurlyOpen 61 : 1, //FunctionStatementCurlyOpen 62 : 1, //FunctionStatementCurlyClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 70 : 1, //IfStatementParenClose 71 : 1, //IfStatementCurlyOpen 72 : 1, //IfStatementCurlyClose 74 : 1, //Infinity 76 : 1, //LabelColon 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 89 : 1, //Nothing 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 111 : 1, //Return 112 : 1, //RegExp 115 : 1, //String 120 : 1, //SwitchStatementParenClose 121 : 1, //SwitchStatementCurlyOpen 122 : 1, //SwitchStatementCurlyClose 123 : 1, //SwitchColon 124 : 1, //This 128 : 1, //TryStatementCurlyOpen 129 : 1, //TryStatementCurlyClose 130 : 1, //True 135 : 1, //Undefined 137 : 1, //VarIdentifier 142 : 1, //WithStatementParenClose 143 : 1, //WithStatementCurlyOpen 144 : 1, //WithStatementCurlyClose 147 : 1, //WhileStatementParenClose 148 : 1, //WhileStatementCurlyOpen 149 : 1 //WhileStatementCurlyClose }, 150 : {//Xor 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 151 : {//XorAssignment 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 152 : {//ZeroRightShift 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 107 : 1, //PostfixIncrement 108 : 1, //PostfixDeincrement 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier }, 153 : {//ZeroRightShiftAssignment 2 : 1, //ArrayClose 4 : 1, //AccessorClose 36 : 1, //False 47 : 1, //FunctionCallClose 63 : 1, //FunctionExpressionCurlyClose 67 : 1, //Identifier 74 : 1, //Infinity 83 : 1, //NaN 85 : 1, //Number 86 : 1, //Null 97 : 1, //ObjectLiteralCurlyClose 106 : 1, //ParenExpressionClose 112 : 1, //RegExp 115 : 1, //String 124 : 1, //This 130 : 1, //True 135 : 1, //Undefined 137 : 1 //VarIdentifier } }; exports.version = "0.4.0"; exports.parse = function() { var js = MentalJS(); }; MentalJS = function() { function Mental() { var that = this,scoping = '$', replaceScoping = new RegExp('[' + scoping + ']'), attributeWhitelist = /^(?:style|accesskey|align|alink|alt|bgcolor|border|cellpadding|cellspacing|class|color|cols|colspan|coords|dir|face|height|hspace|id|ismap|lang|marginheight|marginwidth|multiple|name|nohref|noresize|noshade|nowrap|ref|rel|rev|rows|rowspan|scrolling|size|shape|span|summary|tabindex|target|title|type|usemap|valign|value|vlink|vspace|width)$/i, attributeWhitelistList = 'accesskey|align|alink|alt|bgcolor|border|cellpadding|cellspacing|class|color|cols|colspan|coords|dir|face|height|hspace|id|ismap|lang|marginheight|marginwidth|multiple|name|nohref|noresize|noshade|nowrap|ref|rel|rev|rows|rowspan|scrolling|size|shape|span|summary|tabindex|target|title|type|usemap|valign|value|vlink|vspace|width'.split('|'), urlBasedAttributes = /^(?:href|src|action)$/i, urlBasedAttributesList = ['href', 'src', 'action'], allowedEvents = /^(?:onabort|onactivate|onafterprint|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbegin|onblur|onbounce|oncellchange|onchange|onclick|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondblclick|ondeactivate|ondrag|ondragend|ondragleave|ondragenter|ondragover|ondragdrop|ondrop|onend|onerror|onerrorupdate|onexit|onfilterchange|onfinish|onfocus|onfocusin|onfocusout|onhelp|onkeydown|onkeypress|onkeyup|onlayoutcomplete|onload|onlosecapture|onmediacomplete|onmediaerror|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onmove|onmoveend|onmovestart|onoutofsync|onpaste|onpause|onprogress|onpropertychange|onreadystatechange|onrepeat|onreset|onresize|onresizeend|onresizestart|onresume|onreverse|onrowenter|onrowexit|onrowdelete|onrowinserted|onscroll|onseek|onselect|onselectionchange|onselectstart|onstart|onstop|onsynchrestored|onsubmit|ontimeerror|ontrackchange|onunload|onurlflip|seeksegmenttime|oncanplay|oncanplaythrough|ondragstart|ondurationchange|onemptied|onended|onloadeddata|onloadedmetadata|onloadstart|onmessage|onoffline|ononline|onplay|onplaying|onratechange|onsearch|onseeked|onseeking|onstalled|onstorage|onsuspend|ontimeupdate|onvolumechange|onwaiting|onwebkitanimationend|onwebkitanimationiteration|onwebkitanimationstart|onwebkittransitionend)$/i, allowedEventsList = 'onabort|onactivate|onafterprint|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbegin|onblur|onbounce|oncellchange|onchange|onclick|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondblclick|ondeactivate|ondrag|ondragend|ondragleave|ondragenter|ondragover|ondragdrop|ondrop|onend|onerror|onerrorupdate|onexit|onfilterchange|onfinish|onfocus|onfocusin|onfocusout|onhelp|onkeydown|onkeypress|onkeyup|onlayoutcomplete|onload|onlosecapture|onmediacomplete|onmediaerror|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onmove|onmoveend|onmovestart|onoutofsync|onpaste|onpause|onprogress|onpropertychange|onreadystatechange|onrepeat|onreset|onresize|onresizeend|onresizestart|onresume|onreverse|onrowenter|onrowexit|onrowdelete|onrowinserted|onscroll|onseek|onselect|onselectionchange|onselectstart|onstart|onstop|onsynchrestored|onsubmit|ontimeerror|ontrackchange|onunload|onurlflip|seeksegmenttime|oncanplay|oncanplaythrough|ondragstart|ondurationchange|onemptied|onended|onloadeddata|onloadedmetadata|onloadstart|onmessage|onoffline|ononline|onplay|onplaying|onratechange|onsearch|onseeked|onseeking|onstalled|onstorage|onsuspend|ontimeupdate|onvolumechange|onwaiting|onwebkitanimationend|onwebkitanimationiteration|onwebkitanimationstart|onwebkittransitionend'.split('|'), allowedTagsRegEx = /^(?:a|b|h[1-6]|script|head|title|style|link|body|form|font|select|optgroup|option|input|textarea|button|label|fieldset|legend|ul|ol|dl|directory|menu|nav|li|div|p|heading|quote|pre|br|hr|img|image|map|area|table|code|caption|th|section|tr|td|tbody|iframe)$/i, allowedCSSProperties = ["azimuth", "background", "backgroundAttachment", "backgroundColor", "backgroundImage", "backgroundPosition", "backgroundRepeat", "border", "borderCollapse", "borderColor", "borderSpacing", "borderStyle", "borderTop", "borderRight", "borderBottom", "borderLeft", "borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor", "borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle", "borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth", "borderWidth", "bottom", "captionSide", "clear", "clip", "color", "content", "counterIncrement", "counterReset", "cue", "cueAfter", "cueBefore", "cursor", "direction", "display", "elevation", "emptyCells", "float", "font", "fontFamily", "fontSize", "fontSizeAdjust", "fontStretch", "fontStyle", "fontVariant", "fontWeight", "height", "left", "letterSpacing", "lineHeight", "listStyle", "listStyleImage", "listStylePosition", "listStyleType", "margin", "marginTop", "marginRight", "marginBottom", "marginLeft", "markerOffset", "marks", "maxHeight", "maxWidth", "minHeight", "minWidth", "orphans", "outline", "outlineColor", "outlineStyle", "outlineWidth", "overflow", "padding", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "page", "pageBreakAfter", "pageBreakBefore", "pageBreakInside", "pause", "pauseAfter", "pauseBefore", "pitch", "pitchRange", "playDuring", "position", "quotes", "richness", "right", "size", "speak", "speakHeader", "speakNumeral", "speakPunctuation", "speechRate", "stress", "tableLayout", "textAlign", "textDecoration", "textIndent", "textShadow", "textTransform", "top", "unicodeBidi", "verticalAlign", "visibility", "voiceFamily", "volume", "whiteSpace", "widows", "width", "wordSpacing", "zIndex"], setTimeoutIDS = {}, setIntervalIDS = {}; this.init = init; function init(config) { M = { O : function(obj) { var keys = Object.keys(obj), key; for (key in obj) { if (!/.+[$]$/.test(key)) { continue; } if (/^(?:toString|valueOf|constructor|hasOwnProperty)[$]$/.test(key)) { Object.defineProperty(obj, key.replace(new RegExp(replaceScoping.source + '$', 'i'), ''), { configurable : true, enumerable : false, writable : true }); Object.defineProperty(obj, key, { value : obj[key], enumerable : false, writable : true, configurable : true }); } else { if (key === 'length$') { Object.defineProperty(obj, key.replace(new RegExp(replaceScoping.source + '$', 'i'), ''), { configurable : true, enumerable : true, writable : true, value : obj[key] }); Object.defineProperty(obj, key, { set : function(len) { this.length = len; }, get : function() { return this.length; }, enumerable : false, configurable : true }); continue; } Object.defineProperty(obj, key.replace(new RegExp(replaceScoping.source + '$', 'i'), ''), { configurable : true, enumerable : true, writable : true }); Object.defineProperty(obj, key, { value : obj[key], enumerable : false, writable : true, configurable : true }); } } return obj; }, P : function() { var exp = arguments[arguments.length - 1]; if ( typeof exp === 'undefined') { return null; } if ((/[^\d]/.test(exp) || exp === '')) { return exp + scoping; } else { return +exp; } }, A : function(args) { args = [].slice.call(args, 0); args.callee$ = arguments.callee.caller; return args; } }; function defineStyle(obj, property) { Object.defineProperty(obj, property + '$', { configurable : true, get : function() { return this[property]; }, set : function(value) { this[property] = value; } }); } function createSandboxedNode(node) { for (var i = 0; i < allowedEventsList.length; i++) { Object.defineProperty(node, allowedEventsList[i] + scoping, { configurable : true, get : function(attr) { return function() { return this[attr]; } }(allowedEventsList[i]), set : function(attr) { return function(val) { if ( typeof val === 'function') { return this[attr] = val; } } }(allowedEventsList[i]) }); } for (var i = 0; i < attributeWhitelistList.length; i++) { Object.defineProperty(node, attributeWhitelistList[i] + scoping, { configurable : true, get : function(attr) { return function() { return this[attr]; } }(attributeWhitelistList[i]), set : function(attr) { return function(val) { return this[attr] = val; } }(attributeWhitelistList[i]) }); } for (var i = 0; i < urlBasedAttributesList.length; i++) { Object.defineProperty(node, urlBasedAttributesList[i] + scoping, { configurable : true, get : function(attr) { return function() { return this[attr]; } }(urlBasedAttributesList[i]), set : function(attr) { var anchor = document.createElement('a'); return function(val) { anchor.href = val + ''; if ((anchor.protocol === 'http:' || anchor.protocol === 'https:') && anchor.host.replace(/:\d+$/, '') === location.host.replace(/:\d+$/, '')) { return this[attr] = val; } } }(urlBasedAttributesList[i]) }); } Object.defineProperties(node, { 'innerText$' : { configurable : true, get : function() { return this.innerText; }, set : function(innerText) { this.innerText = innerText; } }, 'innerHTML$' : { configurable : true, get : function() { return this.innerHTML; }, set : function(innerHTML) { var clean = config.parseInnerHTML(innerHTML); this.innerHTML = clean; return this.innerHTML; } }, 'textContent$' : { configurable : true, get : function() { return this.textContent; }, set : function(textContent) { this.textContent = textContent; } }, 'style$' : { configurable : true, get : function() { var style = this.style, i; for ( i = 0; i < allowedCSSProperties.length; i++) { defineStyle(style, allowedCSSProperties[i]); } //todo CSS parsing Object.defineProperty(this.style, 'cssText$', { configurable : true, get : function() { return this.cssText; }, set : function(val) { this.cssText = val; } }); return style; } }, 'appendChild$' : { configurable : true, writable : false, value : function(node) { var js, script, code; if (this.tagName && this.tagName.toUpperCase() == 'SCRIPT') { while (this.firstChild) { this.removeChild(this.firstChild); } js = MentalJS(); code = document.createTextNode(js.parse({ options : { eval : false }, code : node.textContent })); script = document.createElement('script'); script.appendChild(code); return this.appendChild(script); } return this.appendChild(node); } }, 'value$' : { configurable : true, set : function(val) { this.value = val; }, get : function() { return this.value; } }, 'ownerDocument$' : { configurable : true, get : function() { return this.ownerDocument; } }, 'nodeName$' : { enumerable : false, configurable : true, writable : false, value : document.nodeName }, 'tagName$' : { configurable : true, get : function() { return this.tagName; } }, 'nodeType$' : { configurable : true, get : function() { return this.nodeType; } }, 'childNodes$' : { configurable : true, get : function() { return this.childNodes; } }, 'firstChild$' : { configurable : true, get : function() { return this.firstChild; } }, 'lastChild$' : { configurable : true, get : function() { return this.lastChild; } }, 'nextSibling$' : { configurable : true, get : function() { return this.nextSibling; } }, 'parentNode$' : { configurable : true, get : function() { return this.parentNode; } }, 'insertBefore$' : { configurable : true, writable : false, value : function(newElement, referenceElement) { var js, script, code; if (this.tagName && this.tagName.toUpperCase() == 'SCRIPT') { while (this.firstChild) { this.removeChild(this.firstChild); } js = MentalJS(); code = document.createTextNode(js.parse({ options : { eval : false }, code : newElement.textContent })); return this.insertBefore(code, referenceElement); } return this.insertBefore.apply(this, arguments); } }, 'cloneNode$' : { configurable : true, writable : false, value : function() { return this.cloneNode.apply(this, arguments); } }, 'removeChild$' : { configurable : true, writable : false, value : function() { return this.removeChild.apply(this, arguments); } }, 'removeAttribute$' : { configurable : true, writable : false, value : function(name) { this.removeAttribute(name); } }, 'getAttribute$' : { configurable : true, writable : false, value : function(name) { if (attributeWhitelist.test(name)) { return this.getAttribute(name); } } }, 'setAttribute$' : { configurable : true, writable : false, value : function(name, value) { var anchor; if (attributeWhitelist.test(name)) { if (urlBasedAttributes.test(name)) { anchor = document.createElement('a'); anchor.href = value; if ((anchor.protocol === 'http:' || anchor.protocol === 'https:') && anchor.host.replace(/:\d+$/, '') === location.host.replace(/:\d+$/, '')) { value = anchor.href + ''; } else { value = '#'; } anchor = null; } return this.setAttribute(name, value + ''); } } }, 'getElementsByTagName$' : { configurable : true, writable : false, value : function() { return this.getElementsByTagName.apply(this, arguments); } } }); return node; } function objWhitelist(obj, list, noprototype) { list = list.split(','); for (var i = 0; i < list.length; i++) { var prop = list[i]; if (noprototype) { Object.defineProperty(obj, prop + scoping, { value : obj[prop], configurable : true, enumerable : false, writable : false }); } else { Object.defineProperty(obj.prototype, prop + scoping, { writable : false, configurable : true, enumerable : false, value : obj.prototype[prop] }); } } return obj; } function constWhitelist(obj, list, transObj) { list = list.split(','); for (var i = 0; i < list.length; i++) { var prop = list[i]; if (transObj) { Object.defineProperty(transObj, prop + scoping, { value : obj[prop], configurable : true, enumerable : false, writable : false }); } else { Object.defineProperty(obj, prop + scoping, { value : obj[prop], configurable : true, enumerable : false, writable : false }); } } } function FUNCTION() { var args = arguments, converted, js = MentalJS(), i, funct, functArgs = []; if (args.length > 1) { funct = '(function anonymous('; for ( i = 0; i < args.length - 1; i++) { args[i] = args[i] + ''; args[i] = args[i].replace(/[^\w]/ig, function(c) { if (c.charCodeAt(0) < 0x80) { return ''; } }); functArgs.push(args[i]); } funct += functArgs.join(','); funct += '){' + args[args.length - 1] + '})'; converted = js.parse(funct); } else { funct = '(function anonymous(){' + args[0] + '})'; converted = js.parse(funct); } if (config.functionCode) { config.functionCode(converted); } return converted; } FUNCTION.constructor$ = FUNCTION; Function$ = FUNCTION; Boolean.constructor$ = Function$; Boolean.prototype.constructor$ = Boolean; Boolean$ = Boolean; Function.prototype.constructor$ = Function$; objWhitelist(Function, 'call,apply'); objWhitelist(String, 'charAt,charCodeAt,concat,indexOf,lastIndexOf,localeCompare,match,replace,search,slice,split,substr,substring,toLocaleLowerCase,toLocaleString,toLocaleUpperCase,toLowerCase,toUpperCase'); String = objWhitelist(String, 'fromCharCode', true); String.prototype.constructor$ = String; String.constructor$ = Function$; String$ = String; objWhitelist(Array, 'sort,join,pop,push,reverse,shift,slice,splice,unshift,concat'); Array.prototype.constructor$ = Array; Array.constructor$ = Function$; Array$ = Array; objWhitelist(RegExp, 'compile,exec,test'); RegExp.prototype.constructor$ = RegExp; Object.defineProperty(RegExp.prototype, 'source$', { configurable : true, get : function() { return this.source } }); RegExp.lastMatch$ = RegExp.lastMatch; RegExp.lastParen$ = RegExp.lastParen; RegExp.leftContext$ = RegExp.leftContext; RegExp.constructor$ = Function$; RegExp$ = RegExp; objWhitelist(Number, 'toExponential,toFixed,toPrecision'); constWhitelist(Number, 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY'); Number.constructor$ = Function$; Number.prototype.constructor$ = Number; Number$ = Number; objWhitelist(Date, 'getDate,getDay,getFullYear,getHours,getMilliseconds,getMinutes,getMonth,getSeconds,getTime,getTimezoneOffset,getUTCDate,getUTCDay,getUTCFullYear,getUTCHours,getUTCMilliseconds,getUTCMinutes,getUTCMonth,getUTCSeconds,getYear,setDate,setFullYear,setHours,setMilliseconds,setMinutes,setMonth,setSeconds,setTime,setUTCDate,setUTCFullYear,setUTCHours,setUTCMilliseconds,setUTCMinutes,setUTCMonth,setUTCSeconds,setYear,toDateString,toGMTString,toLocaleDateString,toLocaleString,toLocaleTimeString,toTimeString,toUTCString'); Date.prototype.constructor$ = Date; Date.constructor$ = Function$; Date$ = Date; objWhitelist(Math, 'abs,acos,asin,atan,atan2,ceil,cos,exp,floor,log,max,min,pow,random,round,sin,sqrt,tan', true); constWhitelist(Math, 'E,LN10,LN2,LOG10E,LOG2E,PI,SQRT1_2,SQRT2'); Math.constructor$ = Object; Math$ = Math; constWhitelist(window, 'decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,escape,isFinite,isNaN,parseFloat,parseInt,unescape', window); function CLEAR_INTERVAL(id) { id = +id; if ( typeof setIntervalIDS[id] === 'undefined') { return null; } return clearInterval(id); } clearInterval$ = CLEAR_INTERVAL; var CLEAR_TIMEOUT = function(id) { id = +id; if ( typeof setTimeoutIDS[id] === 'undefined') { return null; } return clearTimeout(id); }; clearTimeout$ = CLEAR_TIMEOUT; var SET_TIMEOUT = function(func, time) { time = +time; if ( typeof func !== 'function') { func = FUNCTION(func); } var id = +setTimeout(func, time); setTimeoutIDS[id] = true; return id; }; setTimeout$ = SET_TIMEOUT; var SET_INTERVAL = function(func, time) { time = +time; if ( typeof func !== 'function') { func = FUNCTION(func); } var id = +setInterval(func, time); setIntervalIDS[id] = true; return id; }; setInterval$ = SET_INTERVAL; var ALERT = function(str) { alert(str); }; alert$ = ALERT; var EVAL = function(str) { var js = MentalJS(), converted; if ( typeof str !== 'function') { return eval(js.parse({ options : { eval : false }, code : str, converted : function(converted) { if (config.evalCode) { config.evalCode(converted); } } })); } else { if (config.evalCode) { config.evalCode(str); } return eval(str); } }; eval$ = EVAL; Object.constructor$ = Function$; Object.defineProperty(Object.prototype, 'constructor$', { configurable : true, get : function() { return this.constructor; } }); Object.prototype.hasOwnProperty$ = Object.prototype.hasOwnProperty; objWhitelist(Object, 'valueOf'); objWhitelist(Object, 'toString'); Object$ = Object; Object.defineProperty(Object.prototype, 'prototype$', { configurable : true, get : function() { return this.prototype; }, set : function(obj) { this.prototype = obj; } }); Object.defineProperty(Object.prototype, 'length$', { configurable : true, get : function() { return this.length; }, set : function(len) { this.length = len; } }); Object.preventExtensions(Object.prototype); Object.preventExtensions(Array.prototype); Object.defineProperties(window, { 'undefined$' : { configurable : true, writable : false, value : void 1 }, 'document$' : { configurable : true, writable : false, value : document }, 'Object$' : { configurable : true, writable : false, value : Object }, 'eval$' : { configurable : true, writable : false, value : EVAL }, 'alert$' : { configurable : true, writable : false, value : ALERT }, 'setInterval$' : { configurable : true, writable : false, value : SET_INTERVAL }, 'setTimeout$' : { configurable : true, writable : false, value : SET_TIMEOUT }, 'clearInterval$' : { configurable : true, writable : false, value : CLEAR_INTERVAL }, 'clearTimeout$' : { configurable : true, writable : false, value : CLEAR_TIMEOUT }, 'Math$' : { configurable : true, writable : false, value : Math }, 'Date$' : { configurable : true, writable : false, value : Date }, 'Number$' : { configurable : true, writable : false, value : Number }, 'RegExp$' : { configurable : true, writable : false, value : RegExp }, 'Array$' : { configurable : true, writable : false, value : Array }, 'String$' : { configurable : true, writable : false, value : String }, 'Boolean$' : { configurable : true, writable : false, value : Boolean }, 'Function$' : { configurable : true, writable : false, value : FUNCTION }, 'decodeURI$' : { configurable : true, writable : false, value : decodeURI }, 'decodeURIComponent$' : { configurable : true, writable : false, value : decodeURIComponent }, 'encodeURI$' : { configurable : true, writable : false, value : encodeURI }, 'encodeURIComponent$' : { configurable : true, writable : false, value : encodeURIComponent }, 'escape$' : { configurable : true, writable : false, value : escape }, 'isFinite$' : { configurable : true, writable : false, value : isFinite }, 'isNaN$' : { configurable : true, writable : false, value : isNaN }, 'parseFloat$' : { configurable : true, writable : false, value : parseFloat }, 'parseInt$' : { configurable : true, writable : false, value : parseInt }, 'unescape$' : { configurable : true, writable : false, value : unescape }, 'location$' : { configurable : true, writable : false, value : {} }, 'navigator$' : { configurable : true, writable : false, value : {} }, 'removeEventListener$' : { configurable : true, writable : false, value : function() { return window.removeEventListener.apply(document, arguments); } }, 'addEventListener$' : { configurable : true, writable : false, value : function() { if ( typeof arguments[1] !== 'function') { error("Expected function in event listener"); } return window.addEventListener.apply(window, arguments); } } }); if (config.dom) { Object.defineProperties(window.location$, { 'toString' : { configurable : true, value : function() { return 'http://sandboxed'; } }, 'valueOf' : { configurable : true, value : function() { return 'http://sandboxed'; } }, 'href$' : { configurable : true, get : function() { return 'http://sandboxed'; } }, 'replace$' : { configurable : true, get : function() { return function() { }; } }, 'reload$' : { configurable : true, get : function() { return function() { } } }, 'assign$' : { configurable : true, get : function() { return function() { } } }, 'hash$' : { configurable : true, set : function(hash) { location.hash = hash; }, get : function() { return location.hash } }, 'host$' : { configurable : true, get : function() { return 'sandboxed' } }, 'hostname$' : { configurable : true, get : function() { return 'sandboxed' } }, 'pathname$' : { configurable : true, get : function() { return '/' } }, 'port$' : { configurable : true, get : function() { return '' } }, 'protocol$' : { configurable : true, get : function() { return 'http:' } }, 'search$' : { configurable : true, get : function() { return '' } } }); Object.defineProperties(window.navigator$, { 'appCodeName$' : { configurable : true, get : function() { return navigator.appCodeName } }, 'appName$' : { configurable : true, get : function() { return navigator.appName } }, 'appVersion$' : { configurable : true, get : function() { return navigator.appVersion } }, 'language$' : { configurable : true, get : function() { return navigator.language } }, 'onLine$' : { configurable : true, get : function() { return navigator.onLine } }, 'oscpu$' : { configurable : true, get : function() { return navigator.oscpu } }, 'platform$' : { configurable : true, get : function() { return navigator.platform } }, 'product$' : { configurable : true, get : function() { return navigator.product } }, 'productSub$' : { configurable : true, get : function() { return navigator.productSub } }, 'userAgent$' : { configurable : true, get : function() { return navigator.userAgent } }, 'vendor$' : { configurable : true, get : function() { return navigator.vendor } }, 'vendorSub$' : { configurable : true, get : function() { return navigator.vendorSub } } }); Object.defineProperties(document.documentElement, { 'nodeName$' : { enumerable : false, configurable : true, writable : false, value : document.documentElement.nodeName }, 'contains$' : { enumerable : false, configurable : true, writable : false, value : function() { return document.documentElement.contains.apply(document.documentElement, arguments) } }, 'compareDocumentPosition$' : { enumerable : false, configurable : true, writable : false, value : function() { return document.documentElement.compareDocumentPosition.apply(document.documentElement, arguments) } } }); createSandboxedNode(Element.prototype); createSandboxedNode(DocumentFragment.prototype); Object.defineProperties(HTMLScriptElement.prototype, { 'innerText$' : { configurable : true, get : function() { return this.innerText; }, set : function() { } }, 'textContent$' : { configurable : true, get : function() { return this.textContent; }, set : function() { } }, 'text$' : { configurable : true, get : function() { return this.text; }, set : function() { } }, 'innerHTML$' : { configurable : true, get : function() { return this.innerHTML; }, set : function() { } } }); Object.defineProperties(HTMLStyleElement.prototype, { 'innerText$' : { configurable : true, get : function() { return this.innerText; }, set : function(innerText) { this.innerText = innerText; } }, 'textContent$' : { configurable : true, get : function() { return this.textContent; }, set : function(textContent) { this.textContent = textContent; } }, 'text$' : { configurable : true, get : function() { return this.text; }, set : function(text) { this.text = text; } }, 'innerHTML$' : { configurable : true, get : function() { return this.innerHTML; }, set : function() { } } }); Object.defineProperties(document, { 'ownerDocument$' : { configurable : true, get : function() { return document.ownerDocument; } }, 'nodeName$' : { enumerable : false, configurable : true, writable : false, value : document.nodeName }, 'nodeType$' : { enumerable : false, configurable : true, writable : false, value : document.nodeType }, 'compatMode$' : { enumerable : false, configurable : true, writable : false, value : document.compatMode }, 'head$' : { enumerable : false, configurable : true, writable : false, value : document.head }, 'defaultView$' : { enumerable : false, configurable : true, writable : false, value : window }, 'documentElement$' : { enumerable : false, configurable : true, writable : false, value : document.documentElement }, 'readyState$' : { enumerable : false, configurable : true, writable : false, value : document.readyState }, 'body$' : { enumerable : false, configurable : true, writable : false, value : document.body }, 'createTextNode$' : { enumerable : false, configurable : true, writable : false, value : function() { return document.createTextNode.apply(document, arguments) } }, 'createDocumentFragment$' : { enumerable : false, configurable : true, writable : false, value : document.createDocumentFragment }, 'getElementById$' : { enumerable : false, configurable : true, writable : false, value : function() { return document.getElementById.apply(document, arguments) } }, 'getElementsByTagName$' : { enumerable : false, configurable : true, writable : false, value : function() { return document.getElementsByTagName.apply(document, arguments) } }, 'querySelector$' : { enumerable : false, configurable : true, writable : false, value : function() { return document.querySelector.apply(document, arguments) } }, 'querySelectorAll$' : { enumerable : false, configurable : true, writable : false, value : function() { return document.querySelectorAll.apply(document, arguments) } }, 'createElement$' : { enumerable : false, configurable : true, writable : false, value : function(tag) { if (!allowedTagsRegEx.test(tag)) { return false; } return document.createElement.call(document, tag); } }, 'removeEventListener$' : { enumerable : false, configurable : true, writable : false, value : function() { return document.removeEventListener.apply(document, arguments); } }, 'addEventListener$' : { enumerable : false, configurable : true, writable : false, value : function() { if ( typeof arguments[1] != 'function') { error("Expected function in event listener") } return document.addEventListener.apply(document, arguments); } } }); Object.freeze(Element.prototype); Object.freeze(DocumentFragment.prototype); Object.freeze(HTMLScriptElement.prototype); Object.freeze(HTMLStyleElement.prototype); } }; this.parse = function(obj) { if (!Object.defineProperty) { error("MentalJS requires ES5. Please upgrade your browser."); } var parseTreeOutput = '', converted, pos = 0, chr, index, result; function error(str) { var e = new Error(); throw { msg : str + (e.stack ? ' - ' + e.stack : ''), pos : pos, chr : typeof chr === 'undefined' ? '(end)' : chr, state : parseTreeOutput, text : code.slice(pos - 10, pos + 10), code : this.code }; } function execute(code) { var result; window['window' + scoping] = this; result = eval(code); if (that.result) { that.result(result); } return result; } function rewrite(code) { this.code = code; var parentState, parentStates = {}, msg, state = 89, left = 0, output = '', outputLine = '', next, next2, next3, cached = -1, len = code.length, parseTree = that.parseTree, lookupSquare = 1, lookupCurly = 1, lookupParen = 1, ternaryCount = 0, isTernary = {}, caseCount = 0, isCase = {}, isVar = {}, isFor = {}, isForIn = {}, isIf = {}, isObjectLiteral = {}, lastState = 89, newLineFlag = 0, parseTreeFlag = !!that.parseTree, completeFlag = !!that.complete, convertedFlag = !!that.converted, foundKeyword = 0, commentSkip = 0; function asi(useOutput) { var parenIndex = lookupParen - 1, index1 = parseFloat('' + lookupSquare + lookupCurly + parenIndex), index2 = parseFloat('' + lookupSquare + lookupCurly + lookupParen); if (isFor[index1] && !isForIn[index1]) { lastState = 45; if (useOutput) { output += ';'; } else { outputLine += ';'; } if (isFor[index1] > 2) { error("Syntax error unexpected for semi ;"); } isFor[index1]++; isVar[index2] = 0; } else { if (useOutput) { output += ';'; } else { outputLine = ';' + outputLine; } lastState = 35; left = 0; isVar[index2] = 0; } }; function isValidVariable(c) { return c === 170 || c === 181 || c === 186 || c > 191 && c < 215 || c > 215 && c < 247 || c > 247 && c < 706 || c > 709 && c < 722 || c > 735 && c < 741 || c === 748 || c === 750 || c > 879 && c < 885 || c > 885 && c < 888 || c > 889 && c < 894 || c === 902 || c > 903 && c < 907 || c === 908 || c > 909 && c < 930 || c > 930 && c < 1014 || c > 1014 && c < 1154 || c > 1161 && c < 1320 || c > 1328 && c < 1367 || c === 1369 || c > 1376 && c < 1416 || c > 1487 && c < 1515 || c > 1519 && c < 1523 || c > 1567 && c < 1611 || c > 1645 && c < 1648 || c > 1648 && c < 1748 || c === 1749 || c > 1764 && c < 1767 || c > 1773 && c < 1776 || c > 1785 && c < 1789 || c === 1791 || c === 1808 || c > 1809 && c < 1840 || c > 1868 && c < 1958 || c === 1969 || c > 1993 && c < 2027 || c > 2035 && c < 2038 || c === 2042 || c > 2047 && c < 2070 || c === 2074 || c === 2084 || c === 2088 || c > 2111 && c < 2137 || c === 2208 || c > 2209 && c < 2221 || c > 2307 && c < 2362 || c === 2365 || c === 2384 || c > 2391 && c < 2402 || c > 2416 && c < 2424 || c > 2424 && c < 2432 || c > 2436 && c < 2445 || c > 2446 && c < 2449 || c > 2450 && c < 2473 || c > 2473 && c < 2481 || c === 2482 || c > 2485 && c < 2490 || c === 2493 || c === 2510 || c > 2523 && c < 2526 || c > 2526 && c < 2530 || c > 2543 && c < 2546 || c > 2564 && c < 2571 || c > 2574 && c < 2577 || c > 2578 && c < 2601 || c > 2601 && c < 2609 || c > 2609 && c < 2612 || c > 2612 && c < 2615 || c > 2615 && c < 2618 || c > 2648 && c < 2653 || c === 2654 || c > 2673 && c < 2677 || c > 2692 && c < 2702 || c > 2702 && c < 2706 || c > 2706 && c < 2729 || c > 2729 && c < 2737 || c > 2737 && c < 2740 || c > 2740 && c < 2746 || c === 2749 || c === 2768 || c > 2783 && c < 2786 || c > 2820 && c < 2829 || c > 2830 && c < 2833 || c > 2834 && c < 2857 || c > 2857 && c < 2865 || c > 2865 && c < 2868 || c > 2868 && c < 2874 || c === 2877 || c > 2907 && c < 2910 || c > 2910 && c < 2914 || c === 2929 || c === 2947 || c > 2948 && c < 2955 || c > 2957 && c < 2961 || c > 2961 && c < 2966 || c > 2968 && c < 2971 || c === 2972 || c > 2973 && c < 2976 || c > 2978 && c < 2981 || c > 2983 && c < 2987 || c > 2989 && c < 3002 || c === 3024 || c > 3076 && c < 3085 || c > 3085 && c < 3089 || c > 3089 && c < 3113 || c > 3113 && c < 3124 || c > 3124 && c < 3130 || c === 3133 || c > 3159 && c < 3162 || c > 3167 && c < 3170 || c > 3204 && c < 3213 || c > 3213 && c < 3217 || c > 3217 && c < 3241 || c > 3241 && c < 3252 || c > 3252 && c < 3258 || c === 3261 || c === 3294 || c > 3295 && c < 3298 || c > 3312 && c < 3315 || c > 3332 && c < 3341 || c > 3341 && c < 3345 || c > 3345 && c < 3387 || c === 3389 || c === 3406 || c > 3423 && c < 3426 || c > 3449 && c < 3456 || c > 3460 && c < 3479 || c > 3481 && c < 3506 || c > 3506 && c < 3516 || c === 3517 || c > 3519 && c < 3527 || c > 3584 && c < 3633 || c > 3633 && c < 3636 || c > 3647 && c < 3655 || c > 3712 && c < 3715 || c === 3716 || c > 3718 && c < 3721 || c === 3722 || c === 3725 || c > 3731 && c < 3736 || c > 3736 && c < 3744 || c > 3744 && c < 3748 || c === 3749 || c === 3751 || c > 3753 && c < 3756 || c > 3756 && c < 3761 || c > 3761 && c < 3764 || c === 3773 || c > 3775 && c < 3781 || c === 3782 || c > 3803 && c < 3808 || c === 3840 || c > 3903 && c < 3912 || c > 3912 && c < 3949 || c > 3975 && c < 3981 || c > 4095 && c < 4139 || c === 4159 || c > 4175 && c < 4182 || c > 4185 && c < 4190 || c === 4193 || c > 4196 && c < 4199 || c > 4205 && c < 4209 || c > 4212 && c < 4226 || c === 4238 || c > 4255 && c < 4294 || c === 4295 || c === 4301 || c > 4303 && c < 4347 || c > 4347 && c < 4681 || c > 4681 && c < 4686 || c > 4687 && c < 4695 || c === 4696 || c > 4697 && c < 4702 || c > 4703 && c < 4745 || c > 4745 && c < 4750 || c > 4751 && c < 4785 || c > 4785 && c < 4790 || c > 4791 && c < 4799 || c === 4800 || c > 4801 && c < 4806 || c > 4807 && c < 4823 || c > 4823 && c < 4881 || c > 4881 && c < 4886 || c > 4887 && c < 4955 || c > 4991 && c < 5008 || c > 5023 && c < 5109 || c > 5120 && c < 5741 || c > 5742 && c < 5760 || c > 5760 && c < 5787 || c > 5791 && c < 5867 || c > 5869 && c < 5873 || c > 5887 && c < 5901 || c > 5901 && c < 5906 || c > 5919 && c < 5938 || c > 5951 && c < 5970 || c > 5983 && c < 5997 || c > 5997 && c < 6001 || c > 6015 && c < 6068 || c === 6103 || c === 6108 || c > 6175 && c < 6264 || c > 6271 && c < 6313 || c === 6314 || c > 6319 && c < 6390 || c > 6399 && c < 6429 || c > 6479 && c < 6510 || c > 6511 && c < 6517 || c > 6527 && c < 6572 || c > 6592 && c < 6600 || c > 6655 && c < 6679 || c > 6687 && c < 6741 || c === 6823 || c > 6916 && c < 6964 || c > 6980 && c < 6988 || c > 7042 && c < 7073 || c > 7085 && c < 7088 || c > 7097 && c < 7142 || c > 7167 && c < 7204 || c > 7244 && c < 7248 || c > 7257 && c < 7294 || c > 7400 && c < 7405 || c > 7405 && c < 7410 || c > 7412 && c < 7415 || c > 7423 && c < 7616 || c > 7679 && c < 7958 || c > 7959 && c < 7966 || c > 7967 && c < 8006 || c > 8007 && c < 8014 || c > 8015 && c < 8024 || c === 8025 || c === 8027 || c === 8029 || c > 8030 && c < 8062 || c > 8063 && c < 8117 || c > 8117 && c < 8125 || c === 8126 || c > 8129 && c < 8133 || c > 8133 && c < 8141 || c > 8143 && c < 8148 || c > 8149 && c < 8156 || c > 8159 && c < 8173 || c > 8177 && c < 8181 || c > 8181 && c < 8189 || c === 8305 || c === 8319 || c > 8335 && c < 8349 || c === 8450 || c === 8455 || c > 8457 && c < 8468 || c === 8469 || c > 8472 && c < 8478 || c === 8484 || c === 8486 || c === 8488 || c > 8489 && c < 8494 || c > 8494 && c < 8506 || c > 8507 && c < 8512 || c > 8516 && c < 8522 || c === 8526 || c > 8543 && c < 8585 || c > 11263 && c < 11311 || c > 11311 && c < 11359 || c > 11359 && c < 11493 || c > 11498 && c < 11503 || c > 11505 && c < 11508 || c > 11519 && c < 11558 || c === 11559 || c === 11565 || c > 11567 && c < 11624 || c === 11631 || c > 11647 && c < 11671 || c > 11679 && c < 11687 || c > 11687 && c < 11695 || c > 11695 && c < 11703 || c > 11703 && c < 11711 || c > 11711 && c < 11719 || c > 11719 && c < 11727 || c > 11727 && c < 11735 || c > 11735 && c < 11743 || c === 11823 || c > 12292 && c < 12296 || c > 12320 && c < 12330 || c > 12336 && c < 12342 || c > 12343 && c < 12349 || c > 12352 && c < 12439 || c > 12444 && c < 12448 || c > 12448 && c < 12539 || c > 12539 && c < 12544 || c > 12548 && c < 12590 || c > 12592 && c < 12687 || c > 12703 && c < 12731 || c > 12783 && c < 12800 || c > 13311 && c < 19894 || c > 19967 && c < 40909 || c > 40959 && c < 42125 || c > 42191 && c < 42238 || c > 42239 && c < 42509 || c > 42511 && c < 42528 || c > 42537 && c < 42540 || c > 42559 && c < 42607 || c > 42622 && c < 42648 || c > 42655 && c < 42736 || c > 42774 && c < 42784 || c > 42785 && c < 42889 || c > 42890 && c < 42895 || c > 42895 && c < 42900 || c > 42911 && c < 42923 || c > 42999 && c < 43010 || c > 43010 && c < 43014 || c > 43014 && c < 43019 || c > 43019 && c < 43043 || c > 43071 && c < 43124 || c > 43137 && c < 43188 || c > 43249 && c < 43256 || c === 43259 || c > 43273 && c < 43302 || c > 43311 && c < 43335 || c > 43359 && c < 43389 || c > 43395 && c < 43443 || c === 43471 || c > 43519 && c < 43561 || c > 43583 && c < 43587 || c > 43587 && c < 43596 || c > 43615 && c < 43639 || c === 43642 || c > 43647 && c < 43696 || c === 43697 || c > 43700 && c < 43703 || c > 43704 && c < 43710 || c === 43712 || c === 43714 || c > 43738 && c < 43742 || c > 43743 && c < 43755 || c > 43761 && c < 43765 || c > 43776 && c < 43783 || c > 43784 && c < 43791 || c > 43792 && c < 43799 || c > 43807 && c < 43815 || c > 43815 && c < 43823 || c > 43967 && c < 44003 || c > 44031 && c < 55204 || c > 55215 && c < 55239 || c > 55242 && c < 55292 || c > 63743 && c < 64110 || c > 64111 && c < 64218 || c > 64255 && c < 64263 || c > 64274 && c < 64280 || c === 64285 || c > 64286 && c < 64297 || c > 64297 && c < 64311 || c > 64311 && c < 64317 || c === 64318 || c > 64319 && c < 64322 || c > 64322 && c < 64325 || c > 64325 && c < 64434 || c > 64466 && c < 64830 || c > 64847 && c < 64912 || c > 64913 && c < 64968 || c > 65007 && c < 65020 || c > 65135 && c < 65141 || c > 65141 && c < 65277 || c > 65312 && c < 65339 || c > 65344 && c < 65371 || c > 65381 && c < 65471 || c > 65473 && c < 65480 || c > 65481 && c < 65488 || c > 65489 && c < 65496 || c > 65497 && c < 65501; } function isValidVariablePart(c) { return c === 170 || c === 181 || c === 186 || c > 191 && c < 215 || c > 215 && c < 247 || c > 247 && c < 706 || c > 709 && c < 722 || c > 735 && c < 741 || c === 748 || c === 750 || c > 767 && c < 885 || c > 885 && c < 888 || c > 889 && c < 894 || c === 902 || c > 903 && c < 907 || c === 908 || c > 909 && c < 930 || c > 930 && c < 1014 || c > 1014 && c < 1154 || c > 1154 && c < 1160 || c > 1161 && c < 1320 || c > 1328 && c < 1367 || c === 1369 || c > 1376 && c < 1416 || c > 1424 && c < 1470 || c === 1471 || c > 1472 && c < 1475 || c > 1475 && c < 1478 || c === 1479 || c > 1487 && c < 1515 || c > 1519 && c < 1523 || c > 1551 && c < 1563 || c > 1567 && c < 1642 || c > 1645 && c < 1748 || c > 1748 && c < 1757 || c > 1758 && c < 1769 || c > 1769 && c < 1789 || c === 1791 || c > 1807 && c < 1867 || c > 1868 && c < 1970 || c > 1983 && c < 2038 || c === 2042 || c > 2047 && c < 2094 || c > 2111 && c < 2140 || c === 2208 || c > 2209 && c < 2221 || c > 2275 && c < 2303 || c > 2303 && c < 2404 || c > 2405 && c < 2416 || c > 2416 && c < 2424 || c > 2424 && c < 2432 || c > 2432 && c < 2436 || c > 2436 && c < 2445 || c > 2446 && c < 2449 || c > 2450 && c < 2473 || c > 2473 && c < 2481 || c === 2482 || c > 2485 && c < 2490 || c > 2491 && c < 2501 || c > 2502 && c < 2505 || c > 2506 && c < 2511 || c === 2519 || c > 2523 && c < 2526 || c > 2526 && c < 2532 || c > 2533 && c < 2546 || c > 2560 && c < 2564 || c > 2564 && c < 2571 || c > 2574 && c < 2577 || c > 2578 && c < 2601 || c > 2601 && c < 2609 || c > 2609 && c < 2612 || c > 2612 && c < 2615 || c > 2615 && c < 2618 || c === 2620 || c > 2621 && c < 2627 || c > 2630 && c < 2633 || c > 2634 && c < 2638 || c === 2641 || c > 2648 && c < 2653 || c === 2654 || c > 2661 && c < 2678 || c > 2688 && c < 2692 || c > 2692 && c < 2702 || c > 2702 && c < 2706 || c > 2706 && c < 2729 || c > 2729 && c < 2737 || c > 2737 && c < 2740 || c > 2740 && c < 2746 || c > 2747 && c < 2758 || c > 2758 && c < 2762 || c > 2762 && c < 2766 || c === 2768 || c > 2783 && c < 2788 || c > 2789 && c < 2800 || c > 2816 && c < 2820 || c > 2820 && c < 2829 || c > 2830 && c < 2833 || c > 2834 && c < 2857 || c > 2857 && c < 2865 || c > 2865 && c < 2868 || c > 2868 && c < 2874 || c > 2875 && c < 2885 || c > 2886 && c < 2889 || c > 2890 && c < 2894 || c > 2901 && c < 2904 || c > 2907 && c < 2910 || c > 2910 && c < 2916 || c > 2917 && c < 2928 || c === 2929 || c > 2945 && c < 2948 || c > 2948 && c < 2955 || c > 2957 && c < 2961 || c > 2961 && c < 2966 || c > 2968 && c < 2971 || c === 2972 || c > 2973 && c < 2976 || c > 2978 && c < 2981 || c > 2983 && c < 2987 || c > 2989 && c < 3002 || c > 3005 && c < 3011 || c > 3013 && c < 3017 || c > 3017 && c < 3022 || c === 3024 || c === 3031 || c > 3045 && c < 3056 || c > 3072 && c < 3076 || c > 3076 && c < 3085 || c > 3085 && c < 3089 || c > 3089 && c < 3113 || c > 3113 && c < 3124 || c > 3124 && c < 3130 || c > 3132 && c < 3141 || c > 3141 && c < 3145 || c > 3145 && c < 3150 || c > 3156 && c < 3159 || c > 3159 && c < 3162 || c > 3167 && c < 3172 || c > 3173 && c < 3184 || c > 3201 && c < 3204 || c > 3204 && c < 3213 || c > 3213 && c < 3217 || c > 3217 && c < 3241 || c > 3241 && c < 3252 || c > 3252 && c < 3258 || c > 3259 && c < 3269 || c > 3269 && c < 3273 || c > 3273 && c < 3278 || c > 3284 && c < 3287 || c === 3294 || c > 3295 && c < 3300 || c > 3301 && c < 3312 || c > 3312 && c < 3315 || c > 3329 && c < 3332 || c > 3332 && c < 3341 || c > 3341 && c < 3345 || c > 3345 && c < 3387 || c > 3388 && c < 3397 || c > 3397 && c < 3401 || c > 3401 && c < 3407 || c === 3415 || c > 3423 && c < 3428 || c > 3429 && c < 3440 || c > 3449 && c < 3456 || c > 3457 && c < 3460 || c > 3460 && c < 3479 || c > 3481 && c < 3506 || c > 3506 && c < 3516 || c === 3517 || c > 3519 && c < 3527 || c === 3530 || c > 3534 && c < 3541 || c === 3542 || c > 3543 && c < 3552 || c > 3569 && c < 3572 || c > 3584 && c < 3643 || c > 3647 && c < 3663 || c > 3663 && c < 3674 || c > 3712 && c < 3715 || c === 3716 || c > 3718 && c < 3721 || c === 3722 || c === 3725 || c > 3731 && c < 3736 || c > 3736 && c < 3744 || c > 3744 && c < 3748 || c === 3749 || c === 3751 || c > 3753 && c < 3756 || c > 3756 && c < 3770 || c > 3770 && c < 3774 || c > 3775 && c < 3781 || c === 3782 || c > 3783 && c < 3790 || c > 3791 && c < 3802 || c > 3803 && c < 3808 || c === 3840 || c > 3863 && c < 3866 || c > 3871 && c < 3882 || c === 3893 || c === 3895 || c === 3897 || c > 3901 && c < 3912 || c > 3912 && c < 3949 || c > 3952 && c < 3973 || c > 3973 && c < 3992 || c > 3992 && c < 4029 || c === 4038 || c > 4095 && c < 4170 || c > 4175 && c < 4254 || c > 4255 && c < 4294 || c === 4295 || c === 4301 || c > 4303 && c < 4347 || c > 4347 && c < 4681 || c > 4681 && c < 4686 || c > 4687 && c < 4695 || c === 4696 || c > 4697 && c < 4702 || c > 4703 && c < 4745 || c > 4745 && c < 4750 || c > 4751 && c < 4785 || c > 4785 && c < 4790 || c > 4791 && c < 4799 || c === 4800 || c > 4801 && c < 4806 || c > 4807 && c < 4823 || c > 4823 && c < 4881 || c > 4881 && c < 4886 || c > 4887 && c < 4955 || c > 4956 && c < 4960 || c > 4991 && c < 5008 || c > 5023 && c < 5109 || c > 5120 && c < 5741 || c > 5742 && c < 5760 || c > 5760 && c < 5787 || c > 5791 && c < 5867 || c > 5869 && c < 5873 || c > 5887 && c < 5901 || c > 5901 && c < 5909 || c > 5919 && c < 5941 || c > 5951 && c < 5972 || c > 5983 && c < 5997 || c > 5997 && c < 6001 || c > 6001 && c < 6004 || c > 6015 && c < 6100 || c === 6103 || c > 6107 && c < 6110 || c > 6111 && c < 6122 || c > 6154 && c < 6158 || c > 6159 && c < 6170 || c > 6175 && c < 6264 || c > 6271 && c < 6315 || c > 6319 && c < 6390 || c > 6399 && c < 6429 || c > 6431 && c < 6444 || c > 6447 && c < 6460 || c > 6469 && c < 6510 || c > 6511 && c < 6517 || c > 6527 && c < 6572 || c > 6575 && c < 6602 || c > 6607 && c < 6618 || c > 6655 && c < 6684 || c > 6687 && c < 6751 || c > 6751 && c < 6781 || c > 6782 && c < 6794 || c > 6799 && c < 6810 || c === 6823 || c > 6911 && c < 6988 || c > 6991 && c < 7002 || c > 7018 && c < 7028 || c > 7039 && c < 7156 || c > 7167 && c < 7224 || c > 7231 && c < 7242 || c > 7244 && c < 7294 || c > 7375 && c < 7379 || c > 7379 && c < 7415 || c > 7423 && c < 7655 || c > 7675 && c < 7958 || c > 7959 && c < 7966 || c > 7967 && c < 8006 || c > 8007 && c < 8014 || c > 8015 && c < 8024 || c === 8025 || c === 8027 || c === 8029 || c > 8030 && c < 8062 || c > 8063 && c < 8117 || c > 8117 && c < 8125 || c === 8126 || c > 8129 && c < 8133 || c > 8133 && c < 8141 || c > 8143 && c < 8148 || c > 8149 && c < 8156 || c > 8159 && c < 8173 || c > 8177 && c < 8181 || c > 8181 && c < 8189 || c > 8203 && c < 8206 || c > 8254 && c < 8257 || c === 8276 || c === 8305 || c === 8319 || c > 8335 && c < 8349 || c > 8399 && c < 8413 || c === 8417 || c > 8420 && c < 8433 || c === 8450 || c === 8455 || c > 8457 && c < 8468 || c === 8469 || c > 8472 && c < 8478 || c === 8484 || c === 8486 || c === 8488 || c > 8489 && c < 8494 || c > 8494 && c < 8506 || c > 8507 && c < 8512 || c > 8516 && c < 8522 || c === 8526 || c > 8543 && c < 8585 || c > 11263 && c < 11311 || c > 11311 && c < 11359 || c > 11359 && c < 11493 || c > 11498 && c < 11508 || c > 11519 && c < 11558 || c === 11559 || c === 11565 || c > 11567 && c < 11624 || c === 11631 || c > 11646 && c < 11671 || c > 11679 && c < 11687 || c > 11687 && c < 11695 || c > 11695 && c < 11703 || c > 11703 && c < 11711 || c > 11711 && c < 11719 || c > 11719 && c < 11727 || c > 11727 && c < 11735 || c > 11735 && c < 11743 || c > 11743 && c < 11776 || c === 11823 || c > 12292 && c < 12296 || c > 12320 && c < 12336 || c > 12336 && c < 12342 || c > 12343 && c < 12349 || c > 12352 && c < 12439 || c > 12440 && c < 12443 || c > 12444 && c < 12448 || c > 12448 && c < 12539 || c > 12539 && c < 12544 || c > 12548 && c < 12590 || c > 12592 && c < 12687 || c > 12703 && c < 12731 || c > 12783 && c < 12800 || c > 13311 && c < 19894 || c > 19967 && c < 40909 || c > 40959 && c < 42125 || c > 42191 && c < 42238 || c > 42239 && c < 42509 || c > 42511 && c < 42540 || c > 42559 && c < 42608 || c > 42611 && c < 42622 || c > 42622 && c < 42648 || c > 42654 && c < 42738 || c > 42774 && c < 42784 || c > 42785 && c < 42889 || c > 42890 && c < 42895 || c > 42895 && c < 42900 || c > 42911 && c < 42923 || c > 42999 && c < 43048 || c > 43071 && c < 43124 || c > 43135 && c < 43205 || c > 43215 && c < 43226 || c > 43231 && c < 43256 || c === 43259 || c > 43263 && c < 43310 || c > 43311 && c < 43348 || c > 43359 && c < 43389 || c > 43391 && c < 43457 || c > 43470 && c < 43482 || c > 43519 && c < 43575 || c > 43583 && c < 43598 || c > 43599 && c < 43610 || c > 43615 && c < 43639 || c > 43641 && c < 43644 || c > 43647 && c < 43715 || c > 43738 && c < 43742 || c > 43743 && c < 43760 || c > 43761 && c < 43767 || c > 43776 && c < 43783 || c > 43784 && c < 43791 || c > 43792 && c < 43799 || c > 43807 && c < 43815 || c > 43815 && c < 43823 || c > 43967 && c < 44011 || c > 44011 && c < 44014 || c > 44015 && c < 44026 || c > 44031 && c < 55204 || c > 55215 && c < 55239 || c > 55242 && c < 55292 || c > 63743 && c < 64110 || c > 64111 && c < 64218 || c > 64255 && c < 64263 || c > 64274 && c < 64280 || c > 64284 && c < 64297 || c > 64297 && c < 64311 || c > 64311 && c < 64317 || c === 64318 || c > 64319 && c < 64322 || c > 64322 && c < 64325 || c > 64325 && c < 64434 || c > 64466 && c < 64830 || c > 64847 && c < 64912 || c > 64913 && c < 64968 || c > 65007 && c < 65020 || c > 65023 && c < 65040 || c > 65055 && c < 65063 || c > 65074 && c < 65077 || c > 65100 && c < 65104 || c > 65135 && c < 65141 || c > 65141 && c < 65277 || c > 65295 && c < 65306 || c > 65312 && c < 65339 || c === 65343 || c > 65344 && c < 65371 || c > 65381 && c < 65471 || c > 65473 && c < 65480 || c > 65481 && c < 65488 || c > 65489 && c < 65496 || c > 65497 && c < 65501; } function unicodeEscape(first) { pos++; var chr1 = code.charCodeAt(pos), chr2 = code.charAt(pos + 1), chr3 = code.charAt(pos + 2), chr4 = code.charAt(pos + 3), chr5 = code.charAt(pos + 4), hex; if (chr1 !== 0x75) { error("Invalid unicode escape. Expected u."); } hex = +('0x' + chr2 + chr3 + chr4 + chr5); if ((hex === hex && hex !== hex) || /[^a-f0-9]/i.test(''+chr2+chr3+chr4+chr5)) { error("Invalid unicode escape. Expected valid hex sequence."); } if (first) { if (hex > 0x60 && hex < 0x7b) { } else if (hex > 0x40 && hex < 0x5b) { } else if (hex === 0x5f || hex === 0x24) { } else if (!isValidVariable(hex)) { error('illegal unicode escape'); } } else { if (hex > 0x60 && hex < 0x7b) { } else if (hex > 0x2f && hex < 0x3a) { } else if (hex > 0x40 && hex < 0x5b) { } else if (hex === 0x5f || hex === 0x24) { } else if (!isValidVariablePart(hex)) { error('illegal unicode escape'); } } pos += 5; if (first) { if (pos < len) { outputLine += '\\u' + chr2 + chr3 + chr4 + chr5; nonKeyword(); return false; } else { outputLine += '\\u' + chr2 + chr3 + chr4 + chr5 + '$'; identifierStates(); identifierAsi(); } } else { outputLine += '\\u' + chr2 + chr3 + chr4 + chr5; } } function keyword(iLen) { state = -1; index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); left = 0; switch(iLen) { case 2: if (outputLine === 'do') { state = 18; outputLine += ' '; } else if (outputLine === 'in') { state = 73; outputLine = ' ' + outputLine + ' '; if (isFor[index]) { isForIn[index] = 1; } } else if (outputLine === 'if') { state = 68; if (lastState === 32) { outputLine = ' ' + outputLine; } isIf[index] = 1; } break; case 3: if (outputLine === 'var') { if (!rules[136][lastState]) { asi(); } state = 136; outputLine += ' '; isVar[index] = 1; } else if (outputLine === 'new') { state = 84; outputLine += ' '; } else if (outputLine === 'NaN') { state = 83; left = 1; } else if (outputLine === 'for') { state = 40; outputLine += ' '; isFor[index] = 1; } else if (outputLine === 'try') { state = 127; } break; case 4: if (outputLine === 'else') { if (!isIf[index]) { error("Syntax error unexpected else"); } state = 32; outputLine += ' '; } else if (outputLine === 'this') { state = 124; left = 1; } else if (outputLine === 'void') { state = 139; outputLine += ' '; } else if (outputLine === 'case') { state = 15; outputLine += ' '; isCase[index] = 1; caseCount++; } else if (outputLine === 'null') { state = 86; left = 1; } else if (outputLine === 'true') { state = 130; left = 1; } else if (outputLine === 'with') { state = 140; } break; case 5: if (outputLine === 'throw') { state = 131; outputLine += ' '; } else if (outputLine === 'break') { state = 14; outputLine += ' '; } else if (outputLine === 'false') { state = 36; left = 1; } else if (outputLine === 'catch') { state = 22; } else if (outputLine === 'while') { state = 145; } break; case 6: if (outputLine === 'delete') { state = 17; outputLine += ' '; } else if (outputLine === 'return') { state = 111; outputLine += ' '; } else if (outputLine === 'typeof') { state = 132; outputLine += ' '; } else if (outputLine === 'switch') { state = 118; } break; case 7: if (outputLine === 'default') { state = 16; } else if (outputLine === 'finally') { state = 37; } break; default: if (outputLine === 'function') { if (rules[52][lastState]) { state = 52; } else if (rules[60][lastState]) { state = 60; } else { if (!rules[67][lastState] && newLineFlag) { asi(); state = 60; } else { error('Unexpected function. Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } } } else if (outputLine === 'Infinity') { state = 74; left = 1; } else if (outputLine === 'continue') { state = 29; outputLine += ' '; } else if (outputLine === 'instanceof') { state = 75; left = 1; outputLine = ' ' + outputLine + ' '; } break; } if (state > -1) { return true; } else { return false; } } function identifierAsi() { if (!rules[state][lastState] && newLineFlag) { if (left) { asi(true); left = 1; } else { asi(true); } } } function identifier() { var iLen, notKeyword = false; while (pos < len) { chr = code.charCodeAt(pos); if (chr > 0x60 && chr < 0x7b) { } else if (chr > 0x40 && chr < 0x5b) { } else if (chr > 0x2f && chr < 0x3a) { nonKeyword(); return false; } else if (chr === 0x5f || chr === 0x24) { nonKeyword(); return false; } else if (chr === 0x5c) { unicodeEscape(); nonKeyword(); return false; } else { break; } outputLine += code.charAt(pos++); } iLen = outputLine.length; if (iLen === 1 || iLen > 10) { outputLine = outputLine + scoping; identifierStates(); return false; } else { if (!keyword(iLen)) { outputLine = outputLine + scoping; identifierStates(); return false; } } identifierAsi(); } function identifierStates() { if (rules[50][lastState]) { state = 50; outputLine = ' ' + outputLine; } else if (rules[25][lastState]) { state = 25; } else if (rules[98][lastState]) { state = 98; } else if (rules[53][lastState]) { state = 53; outputLine = ' ' + outputLine; } else if (rules[48][lastState]) { state = 48; } else if (rules[55][lastState]) { state = 55; } else if (rules[137][lastState]) { state = 137; left = 1; } else if (rules[67][lastState]) { state = 67; left = 1; } else { if (!rules[67][lastState] && newLineFlag) { asi(true); } state = 67; left = 1; } } function nonKeyword() { while (pos < len) { chr = code.charCodeAt(pos); if (chr > 0x60 && chr < 0x7b) { } else if (chr > 0x2f && chr < 0x3a) { } else if (chr > 0x40 && chr < 0x5b) { } else if (chr === 0x5f || chr === 0x24) { } else if (chr === 0x5c) { unicodeEscape(); continue; } else if (chr > 0x80) { if (!isValidVariablePart(chr)) { break; } } else { break; } outputLine += code.charAt(pos++); } outputLine = outputLine + scoping; identifierStates(); identifierAsi(); } function newLine() { newLineFlag = 1; pos++; if (lastState === 14 || lastState === 29 || lastState === 111) { asi(true); } } function semicolon() { var parentState = parentStates[index], parenIndex = lookupParen - 1, index2 = parseFloat('' + lookupSquare + lookupCurly + parenIndex); index = parseFloat('' + lookupSquare + lookupCurly + lookupParen) if (isFor[index2] && !isForIn[index2]) { state = 45; outputLine += ';'; if (isFor[index2] > 2) { error("Syntax error unexpected for semi ;"); } isFor[index2]++; isVar[index] = 0; } else { state = 35; if (lastState !== 35) { outputLine += ';'; } isVar[index] = 0; } pos++; left = 0; } function plus() { next = code.charCodeAt(pos + 1); cached = -1; if (next === 0x2b && left) { state = 107; outputLine += '++'; pos += 2; left = 1; } else if (next === 0x2b && !left) { state = 110; outputLine += '++'; pos += 2; left = 0; } else if (next === 0x3d) { state = 6; outputLine += '+='; pos += 2; left = 0; } else if (next !== 0x3d && next !== 0x2b && left) { state = 5; outputLine += ' + '; pos++; cached = next; left = 0; } else if (next !== 0x3d && next !== 0x2b && !left) { state = 133; outputLine += '+'; pos++; cached = next; left = 0; } else { error('Unexpected + Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } } function nonStandardComment() { while (pos < len) { chr = code.charCodeAt(pos++); if (chr === 10 || chr === 13 || chr === 8232 || chr == 8233) { break; } } cached = -1; newLineFlag = 1; commentSkip = 1; } function singleComment() { pos += 2; while (pos < len) { chr = code.charCodeAt(pos++); if (chr === 10 || chr === 13 || chr === 8232 || chr == 8233) { break; } } cached = -1; newLineFlag = 1; } function multiComment() { pos += 2; pos = code.indexOf('*/', pos); if (pos >= 0) { pos += 2; } else { error('Unterminated comment'); } cached = -1; } function regex() { var states = { escaping : 0, complete : 0, open : 0, square : 0, flags : {} }; cached = -1; state = 112; left = 1; states.open = 1; outputLine += '/'; pos++; while (pos < len) { if (cached >= 0) { chr = cached; } else { chr = code.charCodeAt(pos); } next = code.charCodeAt(pos + 1); cached = -1; if (chr === 0x2f && !states.escaping && !states.square) { states.open = 0; if (next !== 0x69 && next !== 0x6d && next !== 0x67) { states.complete = 1; } } else if (chr === 0x2f && !states.escaping && states.square) { outputLine += '\\'; } else if (chr === 0x28 && !states.escaping && states.square) { outputLine += '\\'; } else if (chr === 0x29 && !states.escaping && states.square) { outputLine += '\\'; } else if (chr === 0x5b && !states.escaping && states.square) { outputLine += '\\'; } else if (chr === 0x5b && !states.escaping && !states.square) { next2 = code.charCodeAt(pos + 2); if (next === 0x5d || (next === 0x5e && next2 === 0x5d)) { error("Empty character class not allowed."); } states.square = 1; } else if (chr === 0x5c && !states.escaping) { states.escaping = 1; } else if (chr === 0x5c && states.escaping) { states.escaping = 0; } else if (chr === 0x5d && !states.escaping) { states.square = 0; } else if (chr === 10 || chr === 13 || chr === 8232 || chr == 8233) { error("Unterminated regex literal"); } else if (states.escaping) { states.escaping = 0; } else if (!states.open && next !== 0x69 && next !== 0x6d && next !== 0x67) { if (!states.open && (chr === 0x69 || chr === 0x6d || chr === 0x67) && states.flags[chr]) { error("Duplicate regex flag"); } states.complete = 1; } else if (!states.open && (chr === 0x69 || chr === 0x6d || chr === 0x67) && !states.flags[chr]) { states.flags[chr] = 1; } outputLine += code.charAt(pos++); cached = next; if (states.complete) { break; } } if (states.open) { error("Unterminated regex literal"); } } function numberOrHex() { function number() { while (pos < len) { chr = code.charCodeAt(pos); if (chr >= 0x31 && chr <= 0x39) { if (states.e) { states.e = 2; } if (states.e2) { states.e2 = 2; } } else if (chr === 0x30) { if (states.zeroFirst && !states.dot) { pos++; continue; } if (states.e) { states.e = 2; } if (states.e2) { states.e2 = 2; } } else if (chr === 0x65 || chr === 0x45) { if (states.e) { break; } else { states.e = 1; } } else if (chr === 0x2b || chr === 0x2d) { if (states.e === 1 && !states.e2) { states.e = 2; states.e2 = 1; } else { cached = chr; break; } } else if (chr === 0x2e) { if (states.dot || states.e || (states.zeroFirst && states.output.length != 1)) { break; } states.dot = 1; } else { cached = chr; break; } states.output = states.output + code.charAt(pos); pos++; } if (states.zeroFirst && !states.output.length) { states.output = '0'; } else if (states.dotFirst) { if (states.output.length === 1) { error('Expected digit'); } states.output = '0' + states.output; } else if (states.e === 1 || states.e2 === 1) { error('Expected exponent'); } outputLine += states.output; } function hex() { var states = { output : '0x' }; pos++; while (pos < len) { chr = code.charCodeAt(pos); if (chr > 0x2f && chr < 0x3a) { } else if (chr > 0x60 && chr < 0x67) { } else if (chr > 0x40 && chr < 0x47) { } else { break; } states.output = states.output + code.charAt(pos); pos++; } if (states.output.length == 2) { error('Missing hex digits.'); } outputLine += states.output; } var states = { dot : 0, e : 0, e2 : 0, complete : 0, output : '', zeroFirst : 0, dotFirst : 0 }; if (rules[101][lastState]) { state = 101; } else if (rules[85][lastState]) { left = 1; state = 85; } else { if (!rules[85][lastState] && newLineFlag) { asi(); left = 1; state = 85; } } if (chr === 0x2e) { states.output = '.'; states.dot = 1; states.dotFirst = 1; } else if (chr === 0x30) { states.zeroFirst = 1; states.output += '' + code.charAt(pos); } else { states.output = code.charAt(pos); } if (pos < len) { pos++; chr = code.charCodeAt(pos); } if ((chr === 0x78 || chr === 0x58) && pos < len) { hex(); } else { number(); } } function divide() { left = 0; cached = -1; if (next === 0x3d) { state = 7; pos += 2; outputLine += '/='; } else { state = 21; pos++; outputLine += ' / '; cached = next; } } function arrayOrAccessorOpen() { index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); if (!left) { state = 1; } else { state = 3; } outputLine += '['; if (state === 3) { outputLine += 'M.P('; } parentStates[index] = state; left = 0; pos++; lookupSquare++; index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); parentStates[index] = state; } function arrayOrAccessorClose() { lookupSquare--; index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); var parentState = parentStates[index]; if (parentState === 1) { state = 2; left = 1; } else if (parentState === 3) { state = 4; left = 1; outputLine += ')'; } else { error('Unexpected ]. Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } outputLine += ']'; left = 1; pos++; parentStates[index] = null; } function parenOpen() { index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); if (lastState === 50) { state = 51; } else if (lastState === 40) { state = 41; } else if (rules[46][lastState]) { state = 46; } else if (lastState === 68) { state = 69; } else if (lastState === 22) { state = 23; } else if (lastState === 145) { state = 146; } else if (lastState === 118) { state = 119; } else if (lastState === 140) { state = 141; } else if (lastState === 53) { state = 54; } else if (lastState === 52) { state = 54; } else if (rules[104][lastState]) { state = 104; } else { if (!rules[67][lastState] && newLineFlag) { asi(); state = 104; } else { error('Unexpected (. Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } } outputLine += '('; pos++; parentStates[index] = state; left = 0; lookupParen++; } function parenClose() { index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); isVar[index] = null; lookupParen--; index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); parentState = parentStates[index]; if (rules[57][lastState]) { state = 57; } else if (parentState === 46) { state = 47; left = 1; } else if (parentState === 41) { state = 42; left = 0; isFor[index] = 0; isForIn[index] = 0; } else if (parentState === 119) { state = 120; left = 0; } else if (parentState === 23) { state = 24; left = 0; } else if (parentState === 146) { state = 147; left = 0; } else if (parentState === 141) { state = 142; left = 0; } else if (parentState === 69) { state = 70; left = 0; } else if (rules[58][lastState]) { state = 58; } else if (parentState === 104) { state = 106; left = 1; } else { error('Unexpected ). Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } outputLine += ')'; pos++; parentStates[index] = null; } function curlyOpen() { var curlyIndex = lookupCurly + 1, index = parseFloat('' + lookupSquare + curlyIndex + lookupParen); if (lastState === 57) { state = 61; } else if (lastState === 18) { state = 19; } else if (lastState === 32) { state = 33; } else if (lastState === 147) { state = 148; } else if (lastState === 24) { state = 26; } else if (lastState === 42) { state = 43; } else if (lastState === 142) { state = 143; } else if (lastState === 127) { state = 128; } else if (lastState === 120) { state = 121; } else if (lastState === 70) { state = 71; } else if (lastState === 37) { state = 38; } else if (lastState === 58) { state = 59; } else if (rules[96][lastState]) { state = 96; parentStates[index] = state; outputLine += 'M.O('; } else if (rules[9][lastState]) { state = 9; } else { if (!rules[67][lastState] && newLineFlag) { asi(); if (lastState === 45) { state = 96; parentStates[index] = state; outputLine += 'M.O('; } else { state = 9; } } else { error('Unexpected {. Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } } outputLine += '{'; if (state === 61 || state === 59) { outputLine += 'var arguments$=M.A(arguments);'; } pos++; index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); parentStates[index] = state; left = 0; lookupCurly++; } function curlyClose() { var curlyIndex; index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); isVar[index] = null; lookupCurly--; index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); parentState = parentStates[index]; outputLine += '}'; if (parentState === 61) { state = 62; left = 0; } else if (parentState === 33) { state = 34; left = 0; } else if (parentState === 96) { state = 97; left = 1; curlyIndex = lookupCurly + 1; index = parseFloat('' + lookupSquare + curlyIndex + lookupParen); isObjectLiteral[index] = 0; outputLine += ')'; } else if (parentState === 43) { state = 44; left = 0; } else if (parentState === 148) { state = 149; left = 0; } else if (parentState === 26) { state = 27; left = 0; } else if (parentState === 38) { state = 39; left = 0; } else if (parentState === 143) { state = 144; left = 0; } else if (parentState === 128) { state = 129; } else if (parentState === 19) { state = 20; } else if (parentState === 121) { state = 122; left = 0; } else if (parentState === 18) { state = 19; left = 0; expect = 0; } else if (parentState === 71) { state = 72; left = 0; } else if (parentState === 59) { state = 63; left = 1; } else if (parentState === 9) { state = 10; left = 0; } else { error('Unexpected }. Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); parentStates[index] = null; pos++; } function ternaryOpen() { index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); state = 125; outputLine += '?'; left = 0; pos++; if (isTernary[index]) { isTernary[index]++; } else { isTernary[index] = 1; } ternaryCount++; } function comma() { var parentState; index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); parentState = parentStates[index]; if (lastState === 48) { state = 49; } else if (parentState === 1 || lastState === 1) { state = 0; } else if (lastState === 55) { state = 56; } else if (parentState === 104) { state = 105; } else if (isObjectLiteral[index]) { state = 100; } else if (isVar[index]) { state = 138; } else if (isTernary[index]) { error("Syntax error expected :"); } else { state = 28; } outputLine += ','; pos++; left = 0; } function period() { if (left) { state = 66; } else { error('Unexpected . Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } outputLine += '.'; pos++; left = 0; } function colon() { var parentState; index = parseFloat('' + lookupSquare + lookupCurly + lookupParen); parentState = parentStates[index]; if (isTernary[index]) { state = 126; isTernary[index]--; ternaryCount--; } else if (rules[99][lastState]) { state = 99; isObjectLiteral[index] = 1; } else if (isCase[index] || lastState === 16) { state = 123; if (lastState === 15) { error("Syntax error"); } if (lastState !== 16) { isCase[index] = 0; caseCount--; } } else if (!parentState) { state = 76; } else { error('Unexpected : Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } outputLine += ':'; pos++; left = 0; } function string() { var states; if (lastState === 96 || lastState === 100) { state = 102; left = 0; } else { state = 115; left = 1; } states = { escaping : 0, complete : 0 }; states[chr] = 1; outputLine += code.charAt(pos); pos++; while (pos < len) { chr = code.charCodeAt(pos); if (chr === 0x27 && !states.escaping && states[0x27]) { states.complete = 1; } else if (chr === 0x22 && !states.escaping && states[0x22]) { states.complete = 1; } else if (states.escaping && (chr === 10 || chr === 13 || chr === 8232 || chr == 8233)) { pos++; states.escaping = 0; continue; } else if (chr === 0x5c && !states.escaping) { states.escaping = 1; pos++; continue; } else if (chr === 0x5c && states.escaping) { states.escaping = 0; outputLine += '\\'; } else if ((chr === 10 || chr === 13 || chr === 8232 || chr == 8233) && !states.escaping) { error("Unterminated string literal"); } else if (states.escaping) { outputLine += '\\'; states.escaping = 0; } if (states.complete && state === 102) { outputLine += scoping; } outputLine += code.charAt(pos); pos++; if (states.complete) { break; } } if (!states.complete) { error("Unterminated string literal"); } } function exclamation() { cached = -1; next = code.charCodeAt(pos + 1); next2 = code.charCodeAt(pos + 2); if (next !== 0x3d && !left) { state = 88; outputLine += ' ! '; pos++; cached = next; } else if (next === 0x3d && next2 !== 0x3d) { state = 87; outputLine += '!='; pos += 2; cached = next2; } else if (next === 0x3d && next2 === 0x3d) { state = 117; outputLine += '!=='; pos += 3; } else { error('Unexpected !. Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } left = 0; } function tilde() { if (!left) { state = 11; outputLine += '~'; pos++; } else { error('Unexpected ~ Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } left = 0; } function pipe() { next = code.charCodeAt(pos + 1); cached = -1; if (next === 0x7c) { state = 81; outputLine += '||'; pos += 2; } else if (next === 0x3d) { state = 103; outputLine += '|='; pos += 2; } else if (next !== 0x7c && next !== 0x3d) { state = 12; outputLine += ' | '; pos++; cached = next; } else { error('Unexpected | Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } left = 0; } function caret() { next = code.charCodeAt(pos + 1); cached = -1; if (next === 0x3d) { state = 151; outputLine += '^='; pos += 2; } else if (next !== 0x3d) { state = 150; outputLine += ' ^ '; pos++; cached = next; } else { error('Unexpected ^. Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } left = 0; } function percent() { next = code.charCodeAt(pos + 1); cached = -1; if (next === 0x3d) { state = 93; outputLine += '%='; pos += 2; } else if (next !== 0x3d) { state = 92; outputLine += ' % '; pos++; cached = next; } else { error('Unexpected % Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } left = 0; } function ampersand() { next = code.charCodeAt(pos + 1); cached = -1; if (next === 0x26) { state = 82; outputLine += '&&'; pos += 2; } else if (next === 0x3d) { state = 8; outputLine += '&='; pos += 2; } else if (next !== 0x26 && next !== 0x3d) { state = 13; outputLine += ' & '; pos++; cached = next; } else { error('Unexpected & Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } left = 0; } function equal() { next = code.charCodeAt(pos + 1); next2 = code.charCodeAt(pos + 2); cached = -1; if (next !== 0x3d) { state = 30; outputLine += ' = '; pos++; cached = next; } else if (next === 0x3d && next2 !== 0x3d) { state = 31; outputLine += '=='; pos += 2; cached = next2; } else if (next === 0x3d && next2 === 0x3d) { state = 116; outputLine += '==='; pos += 3; } else { error('Unexpected = Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } left = 0; } function greaterThan() { next = code.charCodeAt(pos + 1); next2 = code.charCodeAt(pos + 2); next3 = code.charCodeAt(pos + 3); cached = -1; if (next === 0x3e && next2 === 0x3e && next3 === 0x3d) { state = 153; outputLine += '>>>='; pos += 4; } else if (next === 0x3e && next2 === 0x3e) { state = 152; outputLine += '>>>'; pos += 3; cached = next3; } else if (next === 0x3e && next2 === 0x3d) { state = 114; outputLine += '>>='; pos += 3; cached = next3; } else if (next === 0x3e) { state = 113; outputLine += '>>'; pos += 2; cached = next2; } else if (next !== 0x3d) { state = 64; outputLine += ' > '; pos++; cached = next; } else if (next === 0x3d) { state = 65; outputLine += '>='; pos += 2; cached = next2; } else { error('Unexpected > Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } left = 0; } function lessThan() { next = code.charCodeAt(pos + 1); next2 = code.charCodeAt(pos + 2); if (next === 0x21 && next2 === 0x2d) { next3 = code.charCodeAt(pos + 3); if (next3 === 0x2d) { pos += 4; return nonStandardComment(); } } cached = -1; if (next === 0x3c && next2 === 0x3d) { state = 80; outputLine += '<<='; pos += 3; } else if (next === 0x3c) { state = 79; outputLine += '<<'; pos += 2; cached = next2; } else if (next !== 0x3d) { state = 77; outputLine += ' < '; pos++; cached = next; } else if (next === 0x3d) { state = 78; outputLine += '<='; pos += 2; cached = next2; } else { error('Unexpected < Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } left = 0; } function asterix() { next = code.charCodeAt(pos + 1); cached = -1; if (next !== 0x3d) { state = 94; outputLine += ' * '; pos++; cached = next; } else if (next === 0x3d) { state = 95; outputLine += '*='; pos += 2; } else { error('Unexpected * Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } left = 0; } function minus() { next = code.charCodeAt(pos + 1); cached = -1; if (!left) { next2 = code.charCodeAt(pos + 2); if (next === 0x2d && next2 === 0x3e) { pos += 3; return nonStandardComment(); } } if (next === 0x2d && left) { state = 108; outputLine += '--'; pos += 2; left = 1; } else if (next === 0x2d && !left) { state = 109; outputLine += '--'; pos += 2; left = 0; } else if (next === 0x3d) { state = 91; outputLine += '-='; pos += 2; left = 0; } else if (next !== 0x3d && next !== 0x2d && left) { state = 90; outputLine += ' - '; pos++; cached = next; left = 0; } else if (next !== 0x3d && next !== 0x2d && !left) { state = 134; outputLine += '-'; pos++; cached = next; left = 0; } else { error('Unexpected - Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } } function space() { pos++; } function checkRules() { if (state === 89) { error("No state defined for char:" + String.fromCharCode(chr) + ', left: ' + left + ', last state: ' + rulesLookup[lastState] + ',output:' + output); } if (!rules[state]) { error("State does not exist in the rules:" + rulesLookup[state]); } if (!rules[state][lastState] && newLineFlag) { asi(); } if (!rules[state][lastState]) { error("Unexpected " + rulesLookup[state] + '. Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } if (parseTreeFlag) { parseTreeOutput = parseTreeOutput + '<' + rulesLookup[state] + '>' + outputLine + ''; } lastState = state; newLineFlag = 0; if (lookupSquare === 1 && lookupCurly === 1 && lookupParen === 1) { parentStates = {}; } } while (pos < len) { state = 89; if (cached >= 0) { chr = cached; } else { chr = code.charCodeAt(pos); } cached = -1; if (chr === 9 || chr === 11 || chr === 12 || chr === 32) { space(); continue; } else if (chr === 10 || chr === 13) { newLine(); continue; } else if (chr === 0x3b) { semicolon(); } else if (chr > 0x60 && chr < 0x7b) { identifier(); } else if (chr === 0x24) { nonKeyword(); } else if (chr > 0x2f && chr < 0x3a) { numberOrHex(); } else if (chr === 0x2f) { next = code.charCodeAt(pos + 1); if (!left && next !== 0x2a && next !== 0x2f && lastState !== 137) { regex(); } else if (next === 0x2f) { singleComment(); continue; } else if (next === 0x2a) { multiComment(); continue; } else if ((lastState === 137 || left) && next !== 0x2f) { divide(); } else { error('Unexpected /. Cannot follow ' + rulesLookup[lastState] + '.Output:' + output); } } else if (chr === 0x2b) { plus(); } else if (chr === 0x5b) { arrayOrAccessorOpen(); } else if (chr === 0x5d) { arrayOrAccessorClose(); } else if (chr === 0x28) { parenOpen(); } else if (chr === 0x29) { parenClose(); } else if (chr === 0x7b) { curlyOpen(); } else if (chr === 0x7d) { curlyClose(); } else if (chr === 0x3f) { ternaryOpen(); } else if (chr === 0x2c) { comma(); } else if (chr === 0x2e && left) { period(); } else if (chr === 0x3a) { colon(); } else if (chr === 0x27) { string(); } else if (chr === 0x22) { string(); } else if (chr === 0x21) { exclamation(); } else if (chr === 0x7e) { tilde(); } else if (chr === 0x7c) { pipe(); } else if (chr === 0x5e) { caret(); } else if (chr === 0x25) { percent(); } else if (chr === 0x26) { ampersand(); } else if (chr === 0x3d) { equal(); } else if (chr === 0x3e) { greaterThan(); } else if (chr === 0x3c) { lessThan(); } else if (chr === 0x2a) { asterix(); } else if (chr === 0x2d) { minus(); } else if (chr === 0x5f) { nonKeyword(); } else if (chr === 0x5c) { unicodeEscape(1); } else if (chr > 0x40 && chr < 0x5b) { if (chr === 0x49 || chr === 0x4e || chr === 0x49) { identifier(); } else { nonKeyword(); } } else if (!left && chr === 0x2e) { numberOrHex(); } else if (chr > 159) { if (chr === 160 || chr === 5760 || chr === 6158 || chr === 8192 || chr === 8193 || chr === 8194 || chr === 8195 || chr === 8196 || chr === 8197 || chr === 8198 || chr === 8199 || chr === 8200 || chr === 8201 || chr === 8202 || chr === 8239 || chr === 8287 || chr === 12288) { space(); continue; } else if (chr === 8232 || chr == 8233) { newLine(); continue; } else { nonKeyword(); } } if (commentSkip) { commentSkip = 0; continue; } checkRules(); output += outputLine; outputLine = ''; } if (lastState === 70) { error("Syntax error"); } if (lookupSquare > 1) { error("Syntax error unmatched ["); } else if (lookupCurly > 1) { error("Syntax error unmatched {"); } else if (lookupParen > 1) { error("Syntax error unmatched ("); } else if (caseCount > 1) { error("Syntax error unmatched case"); } if (!rules[35][lastState]) { error('Unexpected EOF. ' + rulesLookup[lastState] + ' cannot follow EOF.'); } if (completeFlag) { that.complete(); } if (parseTreeFlag) { that.parseTree(parseTreeOutput); } if (convertedFlag) { that.converted(output); } return output; }; this.options = { eval : true }; if ( typeof obj === 'string') { return execute(rewrite(obj)); } if (obj.options) { this.options = obj.options; } if (obj.converted) { this.converted = obj.converted; } if (obj.result) { this.result = obj.result; } if (obj.complete) { this.complete = obj.complete; } if (obj.parseTree) { this.parseTree = obj.parseTree; } converted = rewrite(obj.code); if (this.options.eval) { return execute(converted); } else { return converted; } }; }; return new Mental; }; })( typeof exports === "undefined" ? (window.mentaljs = {}) : exports); ================================================ FILE: demos/trusted-types-demo.html ================================================ Trusted Types DOMPurify demo
================================================ FILE: dist/purify.cjs.d.ts ================================================ /*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */ import { TrustedTypePolicy, TrustedHTML, TrustedTypesWindow } from 'trusted-types/lib/index.js'; /** * Configuration to control DOMPurify behavior. */ interface Config { /** * Extend the existing array of allowed attributes. * Can be an array of attribute names, or a function that receives * the attribute name and tag name to determine if the attribute is allowed. */ ADD_ATTR?: string[] | ((attributeName: string, tagName: string) => boolean) | undefined; /** * Extend the existing array of elements that can use Data URIs. */ ADD_DATA_URI_TAGS?: string[] | undefined; /** * Extend the existing array of allowed tags. * Can be an array of tag names, or a function that receives * the tag name to determine if the tag is allowed. */ ADD_TAGS?: string[] | ((tagName: string) => boolean) | undefined; /** * Extend the existing array of elements that are safe for URI-like values (be careful, XSS risk). */ ADD_URI_SAFE_ATTR?: string[] | undefined; /** * Allow ARIA attributes, leave other safe HTML as is (default is true). */ ALLOW_ARIA_ATTR?: boolean | undefined; /** * Allow HTML5 data attributes, leave other safe HTML as is (default is true). */ ALLOW_DATA_ATTR?: boolean | undefined; /** * Allow external protocol handlers in URL attributes (default is false, be careful, XSS risk). * By default only `http`, `https`, `ftp`, `ftps`, `tel`, `mailto`, `callto`, `sms`, `cid` and `xmpp` are allowed. */ ALLOW_UNKNOWN_PROTOCOLS?: boolean | undefined; /** * Decide if self-closing tags in attributes are allowed. * Usually removed due to a mXSS issue in jQuery 3.0. */ ALLOW_SELF_CLOSE_IN_ATTR?: boolean | undefined; /** * Allow only specific attributes. */ ALLOWED_ATTR?: string[] | undefined; /** * Allow only specific elements. */ ALLOWED_TAGS?: string[] | undefined; /** * Allow only specific namespaces. Defaults to: * - `http://www.w3.org/1999/xhtml` * - `http://www.w3.org/2000/svg` * - `http://www.w3.org/1998/Math/MathML` */ ALLOWED_NAMESPACES?: string[] | undefined; /** * Allow specific protocols handlers in URL attributes via regex (be careful, XSS risk). * Default RegExp: * ``` * /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i; * ``` */ ALLOWED_URI_REGEXP?: RegExp | undefined; /** * Define how custom elements are handled. */ CUSTOM_ELEMENT_HANDLING?: { /** * Regular expression or function to match to allowed elements. * Default is null (disallow any custom elements). */ tagNameCheck?: RegExp | ((tagName: string) => boolean) | null | undefined; /** * Regular expression or function to match to allowed attributes. * Default is null (disallow any attributes not on the allow list). */ attributeNameCheck?: RegExp | ((attributeName: string, tagName?: string) => boolean) | null | undefined; /** * Allow custom elements derived from built-ins if they pass `tagNameCheck`. Default is false. */ allowCustomizedBuiltInElements?: boolean | undefined; }; /** * Add attributes to block-list. */ FORBID_ATTR?: string[] | undefined; /** * Add child elements to be removed when their parent is removed. */ FORBID_CONTENTS?: string[] | undefined; /** * Extend the existing or default array of forbidden content elements. */ ADD_FORBID_CONTENTS?: string[] | undefined; /** * Add elements to block-list. */ FORBID_TAGS?: string[] | undefined; /** * Glue elements like style, script or others to `document.body` and prevent unintuitive browser behavior in several edge-cases (default is false). */ FORCE_BODY?: boolean | undefined; /** * Map of non-standard HTML element names to support. Map to true to enable support. For example: * * ``` * HTML_INTEGRATION_POINTS: { foreignobject: true } * ``` */ HTML_INTEGRATION_POINTS?: Record | undefined; /** * Sanitize a node "in place", which is much faster depending on how you use DOMPurify. */ IN_PLACE?: boolean | undefined; /** * Keep an element's content when the element is removed (default is true). */ KEEP_CONTENT?: boolean | undefined; /** * Map of MathML element names to support. Map to true to enable support. For example: * * ``` * MATHML_TEXT_INTEGRATION_POINTS: { mtext: true } * ``` */ MATHML_TEXT_INTEGRATION_POINTS?: Record | undefined; /** * Change the default namespace from HTML to something different. */ NAMESPACE?: string | undefined; /** * Change the parser type so sanitized data is treated as XML and not as HTML, which is the default. */ PARSER_MEDIA_TYPE?: DOMParserSupportedType | undefined; /** * Return a DOM `DocumentFragment` instead of an HTML string (default is false). */ RETURN_DOM_FRAGMENT?: boolean | undefined; /** * Return a DOM `HTMLBodyElement` instead of an HTML string (default is false). */ RETURN_DOM?: boolean | undefined; /** * Return a TrustedHTML object instead of a string if possible. */ RETURN_TRUSTED_TYPE?: boolean | undefined; /** * Strip `{{ ... }}`, `${ ... }` and `<% ... %>` to make output safe for template systems. * Be careful please, this mode is not recommended for production usage. * Allowing template parsing in user-controlled HTML is not advised at all. * Only use this mode if there is really no alternative. */ SAFE_FOR_TEMPLATES?: boolean | undefined; /** * Change how e.g. comments containing risky HTML characters are treated. * Be very careful, this setting should only be set to `false` if you really only handle * HTML and nothing else, no SVG, MathML or the like. * Otherwise, changing from `true` to `false` will lead to XSS in this or some other way. */ SAFE_FOR_XML?: boolean | undefined; /** * Use DOM Clobbering protection on output (default is true, handle with care, minor XSS risks here). */ SANITIZE_DOM?: boolean | undefined; /** * Enforce strict DOM Clobbering protection via namespace isolation (default is false). * When enabled, isolates the namespace of named properties (i.e., `id` and `name` attributes) * from JS variables by prefixing them with the string `user-content-` */ SANITIZE_NAMED_PROPS?: boolean | undefined; /** * Supplied policy must define `createHTML` and `createScriptURL`. */ TRUSTED_TYPES_POLICY?: TrustedTypePolicy | undefined; /** * Controls categories of allowed elements. * * Note that the `USE_PROFILES` setting will override the `ALLOWED_TAGS` setting * so don't use them together. */ USE_PROFILES?: false | UseProfilesConfig | undefined; /** * Return entire document including tags (default is false). */ WHOLE_DOCUMENT?: boolean | undefined; } /** * Defines categories of allowed elements. */ interface UseProfilesConfig { /** * Allow all safe MathML elements. */ mathMl?: boolean | undefined; /** * Allow all safe SVG elements. */ svg?: boolean | undefined; /** * Allow all save SVG Filters. */ svgFilters?: boolean | undefined; /** * Allow all safe HTML elements. */ html?: boolean | undefined; } declare const _default: DOMPurify; interface DOMPurify { /** * Creates a DOMPurify instance using the given window-like object. Defaults to `window`. */ (root?: WindowLike): DOMPurify; /** * Version label, exposed for easier checks * if DOMPurify is up to date or not */ version: string; /** * Array of elements that DOMPurify removed during sanitation. * Empty if nothing was removed. */ removed: Array; /** * Expose whether this browser supports running the full DOMPurify. */ isSupported: boolean; /** * Set the configuration once. * * @param cfg configuration object */ setConfig(cfg?: Config): void; /** * Removes the configuration. */ clearConfig(): void; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized TrustedHTML. */ sanitize(dirty: string | Node, cfg: Config & { RETURN_TRUSTED_TYPE: true; }): TrustedHTML; /** * Provides core sanitation functionality. * * @param dirty DOM node * @param cfg object * @returns Sanitized DOM node. */ sanitize(dirty: Node, cfg: Config & { IN_PLACE: true; }): Node; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized DOM node. */ sanitize(dirty: string | Node, cfg: Config & { RETURN_DOM: true; }): Node; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized document fragment. */ sanitize(dirty: string | Node, cfg: Config & { RETURN_DOM_FRAGMENT: true; }): DocumentFragment; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized string. */ sanitize(dirty: string | Node, cfg?: Config): string; /** * Checks if an attribute value is valid. * Uses last set config, if any. Otherwise, uses config defaults. * * @param tag Tag name of containing element. * @param attr Attribute name. * @param value Attribute value. * @returns Returns true if `value` is valid. Otherwise, returns false. */ isValidAttribute(tag: string, attr: string, value: string): boolean; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: BasicHookName, hookFunction: NodeHook): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: ElementHookName, hookFunction: ElementHook): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: DocumentFragmentHookName, hookFunction: DocumentFragmentHook): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: 'uponSanitizeElement', hookFunction: UponSanitizeElementHook): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: 'uponSanitizeAttribute', hookFunction: UponSanitizeAttributeHook): void; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook(entryPoint: BasicHookName, hookFunction?: NodeHook): NodeHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook(entryPoint: ElementHookName, hookFunction?: ElementHook): ElementHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook(entryPoint: DocumentFragmentHookName, hookFunction?: DocumentFragmentHook): DocumentFragmentHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook(entryPoint: 'uponSanitizeElement', hookFunction?: UponSanitizeElementHook): UponSanitizeElementHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook(entryPoint: 'uponSanitizeAttribute', hookFunction?: UponSanitizeAttributeHook): UponSanitizeAttributeHook | undefined; /** * Removes all DOMPurify hooks at a given entryPoint * * @param entryPoint entry point for the hooks to remove */ removeHooks(entryPoint: HookName): void; /** * Removes all DOMPurify hooks. */ removeAllHooks(): void; } /** * An element removed by DOMPurify. */ interface RemovedElement { /** * The element that was removed. */ element: Node; } /** * An element removed by DOMPurify. */ interface RemovedAttribute { /** * The attribute that was removed. */ attribute: Attr | null; /** * The element that the attribute was removed. */ from: Node; } type BasicHookName = 'beforeSanitizeElements' | 'afterSanitizeElements' | 'uponSanitizeShadowNode'; type ElementHookName = 'beforeSanitizeAttributes' | 'afterSanitizeAttributes'; type DocumentFragmentHookName = 'beforeSanitizeShadowDOM' | 'afterSanitizeShadowDOM'; type UponSanitizeElementHookName = 'uponSanitizeElement'; type UponSanitizeAttributeHookName = 'uponSanitizeAttribute'; type HookName = BasicHookName | ElementHookName | DocumentFragmentHookName | UponSanitizeElementHookName | UponSanitizeAttributeHookName; type NodeHook = (this: DOMPurify, currentNode: Node, hookEvent: null, config: Config) => void; type ElementHook = (this: DOMPurify, currentNode: Element, hookEvent: null, config: Config) => void; type DocumentFragmentHook = (this: DOMPurify, currentNode: DocumentFragment, hookEvent: null, config: Config) => void; type UponSanitizeElementHook = (this: DOMPurify, currentNode: Node, hookEvent: UponSanitizeElementHookEvent, config: Config) => void; type UponSanitizeAttributeHook = (this: DOMPurify, currentNode: Element, hookEvent: UponSanitizeAttributeHookEvent, config: Config) => void; interface UponSanitizeElementHookEvent { tagName: string; allowedTags: Record; } interface UponSanitizeAttributeHookEvent { attrName: string; attrValue: string; keepAttr: boolean; allowedAttributes: Record; forceKeepAttr: boolean | undefined; } /** * A `Window`-like object containing the properties and types that DOMPurify requires. */ type WindowLike = Pick & { document?: Document; MozNamedAttrMap?: typeof window.NamedNodeMap; } & Pick; export { _default as default }; export type { Config, DOMPurify, DocumentFragmentHook, ElementHook, HookName, NodeHook, RemovedAttribute, RemovedElement, UponSanitizeAttributeHook, UponSanitizeAttributeHookEvent, UponSanitizeElementHook, UponSanitizeElementHookEvent, WindowLike }; // @ts-ignore export = _default; ================================================ FILE: dist/purify.cjs.js ================================================ /*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */ 'use strict'; const { entries, setPrototypeOf, isFrozen, getPrototypeOf, getOwnPropertyDescriptor } = Object; let { freeze, seal, create } = Object; // eslint-disable-line import/no-mutable-exports let { apply, construct } = typeof Reflect !== 'undefined' && Reflect; if (!freeze) { freeze = function freeze(x) { return x; }; } if (!seal) { seal = function seal(x) { return x; }; } if (!apply) { apply = function apply(func, thisArg) { for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } return func.apply(thisArg, args); }; } if (!construct) { construct = function construct(Func) { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } return new Func(...args); }; } const arrayForEach = unapply(Array.prototype.forEach); const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf); const arrayPop = unapply(Array.prototype.pop); const arrayPush = unapply(Array.prototype.push); const arraySplice = unapply(Array.prototype.splice); const stringToLowerCase = unapply(String.prototype.toLowerCase); const stringToString = unapply(String.prototype.toString); const stringMatch = unapply(String.prototype.match); const stringReplace = unapply(String.prototype.replace); const stringIndexOf = unapply(String.prototype.indexOf); const stringTrim = unapply(String.prototype.trim); const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty); const regExpTest = unapply(RegExp.prototype.test); const typeErrorCreate = unconstruct(TypeError); /** * Creates a new function that calls the given function with a specified thisArg and arguments. * * @param func - The function to be wrapped and called. * @returns A new function that calls the given function with a specified thisArg and arguments. */ function unapply(func) { return function (thisArg) { if (thisArg instanceof RegExp) { thisArg.lastIndex = 0; } for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { args[_key3 - 1] = arguments[_key3]; } return apply(func, thisArg, args); }; } /** * Creates a new function that constructs an instance of the given constructor function with the provided arguments. * * @param func - The constructor function to be wrapped and called. * @returns A new function that constructs an instance of the given constructor function with the provided arguments. */ function unconstruct(Func) { return function () { for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { args[_key4] = arguments[_key4]; } return construct(Func, args); }; } /** * Add properties to a lookup table * * @param set - The set to which elements will be added. * @param array - The array containing elements to be added to the set. * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set. * @returns The modified set with added elements. */ function addToSet(set, array) { let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase; if (setPrototypeOf) { // Make 'in' and truthy checks like Boolean(set.constructor) // independent of any properties defined on Object.prototype. // Prevent prototype setters from intercepting set as a this value. setPrototypeOf(set, null); } let l = array.length; while (l--) { let element = array[l]; if (typeof element === 'string') { const lcElement = transformCaseFunc(element); if (lcElement !== element) { // Config presets (e.g. tags.js, attrs.js) are immutable. if (!isFrozen(array)) { array[l] = lcElement; } element = lcElement; } } set[element] = true; } return set; } /** * Clean up an array to harden against CSPP * * @param array - The array to be cleaned. * @returns The cleaned version of the array */ function cleanArray(array) { for (let index = 0; index < array.length; index++) { const isPropertyExist = objectHasOwnProperty(array, index); if (!isPropertyExist) { array[index] = null; } } return array; } /** * Shallow clone an object * * @param object - The object to be cloned. * @returns A new object that copies the original. */ function clone(object) { const newObject = create(null); for (const [property, value] of entries(object)) { const isPropertyExist = objectHasOwnProperty(object, property); if (isPropertyExist) { if (Array.isArray(value)) { newObject[property] = cleanArray(value); } else if (value && typeof value === 'object' && value.constructor === Object) { newObject[property] = clone(value); } else { newObject[property] = value; } } } return newObject; } /** * This method automatically checks if the prop is function or getter and behaves accordingly. * * @param object - The object to look up the getter function in its prototype chain. * @param prop - The property name for which to find the getter function. * @returns The getter function found in the prototype chain or a fallback function. */ function lookupGetter(object, prop) { while (object !== null) { const desc = getOwnPropertyDescriptor(object, prop); if (desc) { if (desc.get) { return unapply(desc.get); } if (typeof desc.value === 'function') { return unapply(desc.value); } } object = getPrototypeOf(object); } function fallbackValue() { return null; } return fallbackValue; } const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); // List of SVG elements that are disallowed by default. // We still need to know them so that we can do namespace // checks properly in case one wants to add them to // allow-list. const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); // Similarly to SVG, we want to know all MathML elements, // even those that we disallow by default. const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); const text = freeze(['#text']); const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']); const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); // eslint-disable-next-line unicorn/better-regex const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape ); const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex ); const DOCTYPE_NAME = seal(/^html$/i); const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i); var EXPRESSIONS = /*#__PURE__*/Object.freeze({ __proto__: null, ARIA_ATTR: ARIA_ATTR, ATTR_WHITESPACE: ATTR_WHITESPACE, CUSTOM_ELEMENT: CUSTOM_ELEMENT, DATA_ATTR: DATA_ATTR, DOCTYPE_NAME: DOCTYPE_NAME, ERB_EXPR: ERB_EXPR, IS_ALLOWED_URI: IS_ALLOWED_URI, IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA, MUSTACHE_EXPR: MUSTACHE_EXPR, TMPLIT_EXPR: TMPLIT_EXPR }); /* eslint-disable @typescript-eslint/indent */ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType const NODE_TYPE = { element: 1, attribute: 2, text: 3, cdataSection: 4, entityReference: 5, // Deprecated entityNode: 6, // Deprecated progressingInstruction: 7, comment: 8, document: 9, documentType: 10, documentFragment: 11, notation: 12 // Deprecated }; const getGlobal = function getGlobal() { return typeof window === 'undefined' ? null : window; }; /** * Creates a no-op policy for internal use only. * Don't export this function outside this module! * @param trustedTypes The policy factory. * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix). * @return The policy created (or null, if Trusted Types * are not supported or creating the policy failed). */ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) { if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') { return null; } // Allow the callers to control the unique policy name // by adding a data-tt-policy-suffix to the script element with the DOMPurify. // Policy creation with duplicate names throws in Trusted Types. let suffix = null; const ATTR_NAME = 'data-tt-policy-suffix'; if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) { suffix = purifyHostElement.getAttribute(ATTR_NAME); } const policyName = 'dompurify' + (suffix ? '#' + suffix : ''); try { return trustedTypes.createPolicy(policyName, { createHTML(html) { return html; }, createScriptURL(scriptUrl) { return scriptUrl; } }); } catch (_) { // Policy creation failed (most likely another DOMPurify script has // already run). Skip creating the policy, as this will only cause errors // if TT are enforced. console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); return null; } }; const _createHooksMap = function _createHooksMap() { return { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] }; }; function createDOMPurify() { let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); const DOMPurify = root => createDOMPurify(root); DOMPurify.version = '3.3.3'; DOMPurify.removed = []; if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) { // Not running in a browser, provide a factory function // so that you can pass your own Window DOMPurify.isSupported = false; return DOMPurify; } let { document } = window; const originalDocument = document; const currentScript = originalDocument.currentScript; const { DocumentFragment, HTMLTemplateElement, Node, Element, NodeFilter, NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap, HTMLFormElement, DOMParser, trustedTypes } = window; const ElementPrototype = Element.prototype; const cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); const remove = lookupGetter(ElementPrototype, 'remove'); const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); const getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a // new document created via createHTMLDocument. As per the spec // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) // a new empty registry is used when creating a template contents owner // document, so we use that as our parent document to ensure nothing // is inherited. if (typeof HTMLTemplateElement === 'function') { const template = document.createElement('template'); if (template.content && template.content.ownerDocument) { document = template.content.ownerDocument; } } let trustedTypesPolicy; let emptyHTML = ''; const { implementation, createNodeIterator, createDocumentFragment, getElementsByTagName } = document; const { importNode } = originalDocument; let hooks = _createHooksMap(); /** * Expose whether this browser supports running the full DOMPurify. */ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined; const { MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR, DATA_ATTR, ARIA_ATTR, IS_SCRIPT_OR_DATA, ATTR_WHITESPACE, CUSTOM_ELEMENT } = EXPRESSIONS; let { IS_ALLOWED_URI: IS_ALLOWED_URI$1 } = EXPRESSIONS; /** * We consider the elements and attributes below to be safe. Ideally * don't add any new ones but feel free to remove unwanted ones. */ /* allowed element names */ let ALLOWED_TAGS = null; const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]); /* Allowed attribute names */ let ALLOWED_ATTR = null; const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]); /* * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements. * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements) * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list) * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`. */ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, { tagNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, attributeNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, allowCustomizedBuiltInElements: { writable: true, configurable: false, enumerable: true, value: false } })); /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ let FORBID_TAGS = null; /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ let FORBID_ATTR = null; /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, { tagCheck: { writable: true, configurable: false, enumerable: true, value: null }, attributeCheck: { writable: true, configurable: false, enumerable: true, value: null } })); /* Decide if ARIA attributes are okay */ let ALLOW_ARIA_ATTR = true; /* Decide if custom data attributes are okay */ let ALLOW_DATA_ATTR = true; /* Decide if unknown protocols are okay */ let ALLOW_UNKNOWN_PROTOCOLS = false; /* Decide if self-closing tags in attributes are allowed. * Usually removed due to a mXSS issue in jQuery 3.0 */ let ALLOW_SELF_CLOSE_IN_ATTR = true; /* Output should be safe for common template engines. * This means, DOMPurify removes data attributes, mustaches and ERB */ let SAFE_FOR_TEMPLATES = false; /* Output should be safe even for XML used within HTML and alike. * This means, DOMPurify removes comments when containing risky content. */ let SAFE_FOR_XML = true; /* Decide if document with ... should be returned */ let WHOLE_DOCUMENT = false; /* Track whether config is already set on this instance of DOMPurify. */ let SET_CONFIG = false; /* Decide if all elements (e.g. style, script) must be children of * document.body. By default, browsers might move them to document.head */ let FORCE_BODY = false; /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html * string (or a TrustedHTML object if Trusted Types are supported). * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead */ let RETURN_DOM = false; /* Decide if a DOM `DocumentFragment` should be returned, instead of a html * string (or a TrustedHTML object if Trusted Types are supported) */ let RETURN_DOM_FRAGMENT = false; /* Try to return a Trusted Type object instead of a string, return a string in * case Trusted Types are not supported */ let RETURN_TRUSTED_TYPE = false; /* Output should be free from DOM clobbering attacks? * This sanitizes markups named with colliding, clobberable built-in DOM APIs. */ let SANITIZE_DOM = true; /* Achieve full DOM Clobbering protection by isolating the namespace of named * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules. * * HTML/DOM spec rules that enable DOM Clobbering: * - Named Access on Window (§7.3.3) * - DOM Tree Accessors (§3.1.5) * - Form Element Parent-Child Relations (§4.10.3) * - Iframe srcdoc / Nested WindowProxies (§4.8.5) * - HTMLCollection (§4.2.10.2) * * Namespace isolation is implemented by prefixing `id` and `name` attributes * with a constant string, i.e., `user-content-` */ let SANITIZE_NAMED_PROPS = false; const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-'; /* Keep element content when removing element? */ let KEEP_CONTENT = true; /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead * of importing it into a new Document and returning a sanitized copy */ let IN_PLACE = false; /* Allow usage of profiles like html, svg and mathMl */ let USE_PROFILES = {}; /* Tags to ignore content of when KEEP_CONTENT is true */ let FORBID_CONTENTS = null; const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); /* Tags that are safe for data: URIs */ let DATA_URI_TAGS = null; const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); /* Attributes safe for values like "javascript:" */ let URI_SAFE_ATTRIBUTES = null; const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; /* Document namespace */ let NAMESPACE = HTML_NAMESPACE; let IS_EMPTY_INPUT = false; /* Allowed XHTML+XML namespaces */ let ALLOWED_NAMESPACES = null; const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString); let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']); // Certain elements are allowed in both SVG and HTML // namespace. We need to specify them explicitly // so that they don't get erroneously deleted from // HTML namespace. const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']); /* Parsing of strict XHTML documents */ let PARSER_MEDIA_TYPE = null; const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; const DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; let transformCaseFunc = null; /* Keep a reference to config to pass to hooks */ let CONFIG = null; /* Ideally, do not touch anything below this line */ /* ______________________________________________ */ const formElement = document.createElement('form'); const isRegexOrFunction = function isRegexOrFunction(testValue) { return testValue instanceof RegExp || testValue instanceof Function; }; /** * _parseConfig * * @param cfg optional config literal */ // eslint-disable-next-line complexity const _parseConfig = function _parseConfig() { let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; if (CONFIG && CONFIG === cfg) { return; } /* Shield configuration object from tampering */ if (!cfg || typeof cfg !== 'object') { cfg = {}; } /* Shield configuration object from prototype pollution */ cfg = clone(cfg); PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase; /* Set configuration parameters */ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS; ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR; ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES; URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES; DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS; FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS; FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({}); FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({}); USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false; ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false RETURN_DOM = cfg.RETURN_DOM || false; // Default false RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false FORCE_BODY = cfg.FORCE_BODY || false; // Default false SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true IN_PLACE = cfg.IN_PLACE || false; // Default false IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI; NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS; HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS; CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {}; if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; } if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) { CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck; } if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') { CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements; } if (SAFE_FOR_TEMPLATES) { ALLOW_DATA_ATTR = false; } if (RETURN_DOM_FRAGMENT) { RETURN_DOM = true; } /* Parse profile info */ if (USE_PROFILES) { ALLOWED_TAGS = addToSet({}, text); ALLOWED_ATTR = create(null); if (USE_PROFILES.html === true) { addToSet(ALLOWED_TAGS, html$1); addToSet(ALLOWED_ATTR, html); } if (USE_PROFILES.svg === true) { addToSet(ALLOWED_TAGS, svg$1); addToSet(ALLOWED_ATTR, svg); addToSet(ALLOWED_ATTR, xml); } if (USE_PROFILES.svgFilters === true) { addToSet(ALLOWED_TAGS, svgFilters); addToSet(ALLOWED_ATTR, svg); addToSet(ALLOWED_ATTR, xml); } if (USE_PROFILES.mathMl === true) { addToSet(ALLOWED_TAGS, mathMl$1); addToSet(ALLOWED_ATTR, mathMl); addToSet(ALLOWED_ATTR, xml); } } /* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */ if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) { EXTRA_ELEMENT_HANDLING.tagCheck = null; } if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) { EXTRA_ELEMENT_HANDLING.attributeCheck = null; } /* Merge configuration parameters */ if (cfg.ADD_TAGS) { if (typeof cfg.ADD_TAGS === 'function') { EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS; } else { if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { ALLOWED_TAGS = clone(ALLOWED_TAGS); } addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc); } } if (cfg.ADD_ATTR) { if (typeof cfg.ADD_ATTR === 'function') { EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR; } else { if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { ALLOWED_ATTR = clone(ALLOWED_ATTR); } addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc); } } if (cfg.ADD_URI_SAFE_ATTR) { addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc); } if (cfg.FORBID_CONTENTS) { if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { FORBID_CONTENTS = clone(FORBID_CONTENTS); } addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc); } if (cfg.ADD_FORBID_CONTENTS) { if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { FORBID_CONTENTS = clone(FORBID_CONTENTS); } addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc); } /* Add #text in case KEEP_CONTENT is set to true */ if (KEEP_CONTENT) { ALLOWED_TAGS['#text'] = true; } /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ if (WHOLE_DOCUMENT) { addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); } /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ if (ALLOWED_TAGS.table) { addToSet(ALLOWED_TAGS, ['tbody']); delete FORBID_TAGS.tbody; } if (cfg.TRUSTED_TYPES_POLICY) { if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') { throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); } if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') { throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); } // Overwrite existing TrustedTypes policy. trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; // Sign local variables required by `sanitize`. emptyHTML = trustedTypesPolicy.createHTML(''); } else { // Uninitialized policy, attempt to initialize the internal dompurify policy. if (trustedTypesPolicy === undefined) { trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript); } // If creating the internal policy succeeded sign internal variables. if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') { emptyHTML = trustedTypesPolicy.createHTML(''); } } // Prevent further manipulation of configuration. // Not available in IE8, Safari 5, etc. if (freeze) { freeze(cfg); } CONFIG = cfg; }; /* Keep track of all possible SVG and MathML tags * so that we can perform the namespace checks * correctly. */ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]); const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]); /** * @param element a DOM element whose namespace is being checked * @returns Return false if the element has a * namespace that a spec-compliant parser would never * return. Return true otherwise. */ const _checkValidNamespace = function _checkValidNamespace(element) { let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode // can be null. We just simulate parent in this case. if (!parent || !parent.tagName) { parent = { namespaceURI: NAMESPACE, tagName: 'template' }; } const tagName = stringToLowerCase(element.tagName); const parentTagName = stringToLowerCase(parent.tagName); if (!ALLOWED_NAMESPACES[element.namespaceURI]) { return false; } if (element.namespaceURI === SVG_NAMESPACE) { // The only way to switch from HTML namespace to SVG // is via . If it happens via any other tag, then // it should be killed. if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === 'svg'; } // The only way to switch from MathML to SVG is via` // svg if parent is either or MathML // text integration points. if (parent.namespaceURI === MATHML_NAMESPACE) { return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); } // We only allow elements that are defined in SVG // spec. All others are disallowed in SVG namespace. return Boolean(ALL_SVG_TAGS[tagName]); } if (element.namespaceURI === MATHML_NAMESPACE) { // The only way to switch from HTML namespace to MathML // is via . If it happens via any other tag, then // it should be killed. if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === 'math'; } // The only way to switch from SVG to MathML is via // and HTML integration points if (parent.namespaceURI === SVG_NAMESPACE) { return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; } // We only allow elements that are defined in MathML // spec. All others are disallowed in MathML namespace. return Boolean(ALL_MATHML_TAGS[tagName]); } if (element.namespaceURI === HTML_NAMESPACE) { // The only way to switch from SVG to HTML is via // HTML integration points, and from MathML to HTML // is via MathML text integration points if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { return false; } if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { return false; } // We disallow tags that are specific for MathML // or SVG and should never appear in HTML namespace return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); } // For XHTML and XML documents that support custom namespaces if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) { return true; } // The code should never reach this place (this means // that the element somehow got namespace that is not // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES). // Return false just in case. return false; }; /** * _forceRemove * * @param node a DOM node */ const _forceRemove = function _forceRemove(node) { arrayPush(DOMPurify.removed, { element: node }); try { // eslint-disable-next-line unicorn/prefer-dom-node-remove getParentNode(node).removeChild(node); } catch (_) { remove(node); } }; /** * _removeAttribute * * @param name an Attribute name * @param element a DOM node */ const _removeAttribute = function _removeAttribute(name, element) { try { arrayPush(DOMPurify.removed, { attribute: element.getAttributeNode(name), from: element }); } catch (_) { arrayPush(DOMPurify.removed, { attribute: null, from: element }); } element.removeAttribute(name); // We void attribute values for unremovable "is" attributes if (name === 'is') { if (RETURN_DOM || RETURN_DOM_FRAGMENT) { try { _forceRemove(element); } catch (_) {} } else { try { element.setAttribute(name, ''); } catch (_) {} } } }; /** * _initDocument * * @param dirty - a string of dirty markup * @return a DOM, filled with the dirty markup */ const _initDocument = function _initDocument(dirty) { /* Create a HTML document */ let doc = null; let leadingWhitespace = null; if (FORCE_BODY) { dirty = '' + dirty; } else { /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ const matches = stringMatch(dirty, /^[\r\n\t ]+/); leadingWhitespace = matches && matches[0]; } if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) { // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict) dirty = '' + dirty + ''; } const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; /* * Use the DOMParser API by default, fallback later if needs be * DOMParser not work for svg when has multiple root element. */ if (NAMESPACE === HTML_NAMESPACE) { try { doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); } catch (_) {} } /* Use createHTMLDocument in case DOMParser is not available */ if (!doc || !doc.documentElement) { doc = implementation.createDocument(NAMESPACE, 'template', null); try { doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload; } catch (_) { // Syntax error if dirtyPayload is invalid xml } } const body = doc.body || doc.documentElement; if (dirty && leadingWhitespace) { body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null); } /* Work on whole document or just its body */ if (NAMESPACE === HTML_NAMESPACE) { return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; } return WHOLE_DOCUMENT ? doc.documentElement : body; }; /** * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. * * @param root The root element or node to start traversing on. * @return The created NodeIterator */ const _createNodeIterator = function _createNodeIterator(root) { return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null); }; /** * _isClobbered * * @param element element to check for clobbering attacks * @return true if clobbered, false if safe */ const _isClobbered = function _isClobbered(element) { return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function'); }; /** * Checks whether the given object is a DOM node. * * @param value object to check whether it's a DOM node * @return true is object is a DOM node */ const _isNode = function _isNode(value) { return typeof Node === 'function' && value instanceof Node; }; function _executeHooks(hooks, currentNode, data) { arrayForEach(hooks, hook => { hook.call(DOMPurify, currentNode, data, CONFIG); }); } /** * _sanitizeElements * * @protect nodeName * @protect textContent * @protect removeChild * @param currentNode to check for permission to exist * @return true if node was killed, false if left alive */ const _sanitizeElements = function _sanitizeElements(currentNode) { let content = null; /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeElements, currentNode, null); /* Check if element is clobbered or can clobber */ if (_isClobbered(currentNode)) { _forceRemove(currentNode); return true; } /* Now let's check the element's type and name */ const tagName = transformCaseFunc(currentNode.nodeName); /* Execute a hook if present */ _executeHooks(hooks.uponSanitizeElement, currentNode, { tagName, allowedTags: ALLOWED_TAGS }); /* Detect mXSS attempts abusing namespace confusion */ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) { _forceRemove(currentNode); return true; } /* Remove any occurrence of processing instructions */ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) { _forceRemove(currentNode); return true; } /* Remove any kind of possibly harmful comments */ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) { _forceRemove(currentNode); return true; } /* Remove element if anything forbids its presence */ if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) { /* Check if we have a custom element to handle */ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) { if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) { return false; } if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) { return false; } } /* Keep content except for bad-listed elements */ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { const parentNode = getParentNode(currentNode) || currentNode.parentNode; const childNodes = getChildNodes(currentNode) || currentNode.childNodes; if (childNodes && parentNode) { const childCount = childNodes.length; for (let i = childCount - 1; i >= 0; --i) { const childClone = cloneNode(childNodes[i], true); childClone.__removalCount = (currentNode.__removalCount || 0) + 1; parentNode.insertBefore(childClone, getNextSibling(currentNode)); } } } _forceRemove(currentNode); return true; } /* Check whether element has a valid namespace */ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { _forceRemove(currentNode); return true; } /* Make sure that older browsers don't get fallback-tag mXSS */ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) { _forceRemove(currentNode); return true; } /* Sanitize element content to be template-safe */ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) { /* Get the element's text content */ content = currentNode.textContent; arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { content = stringReplace(content, expr, ' '); }); if (currentNode.textContent !== content) { arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); currentNode.textContent = content; } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeElements, currentNode, null); return false; }; /** * _isValidAttribute * * @param lcTag Lowercase tag name of containing element. * @param lcName Lowercase attribute name. * @param value Attribute value. * @return Returns true if `value` is valid, otherwise false. */ // eslint-disable-next-line complexity const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */ if (FORBID_ATTR[lcName]) { return false; } /* Make sure attribute cannot clobber */ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { return false; } /* Allow valid data-* attributes: At least one character after "-" (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) We don't need to check the value; it's always URI safe. */ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || // Alternative, second condition checks if it's an `is`-attribute, AND // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else { return false; } /* Check value is safe. First, is attr inert? If so, is safe */ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) { return false; } else ; return true; }; /** * _isBasicCustomElement * checks if at least one dash is included in tagName, and it's not the first char * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name * * @param tagName name of the tag of the node to sanitize * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false. */ const _isBasicCustomElement = function _isBasicCustomElement(tagName) { return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT); }; /** * _sanitizeAttributes * * @protect attributes * @protect nodeName * @protect removeAttribute * @protect setAttribute * * @param currentNode to sanitize */ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) { /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null); const { attributes } = currentNode; /* Check if we have attributes; if not we might have a text node */ if (!attributes || _isClobbered(currentNode)) { return; } const hookEvent = { attrName: '', attrValue: '', keepAttr: true, allowedAttributes: ALLOWED_ATTR, forceKeepAttr: undefined }; let l = attributes.length; /* Go backwards over all attributes; safely remove bad ones */ while (l--) { const attr = attributes[l]; const { name, namespaceURI, value: attrValue } = attr; const lcName = transformCaseFunc(name); const initValue = attrValue; let value = name === 'value' ? initValue : stringTrim(initValue); /* Execute a hook if present */ hookEvent.attrName = lcName; hookEvent.attrValue = value; hookEvent.keepAttr = true; hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent); value = hookEvent.attrValue; /* Full DOM Clobbering protection via namespace isolation, * Prefix id and name attributes with `user-content-` */ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) { // Remove the attribute with this value _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value value = SANITIZE_NAMED_PROPS_PREFIX + value; } /* Work around a security issue with comments inside attributes */ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) { _removeAttribute(name, currentNode); continue; } /* Make sure we cannot easily use animated hrefs, even if animations are allowed */ if (lcName === 'attributename' && stringMatch(value, 'href')) { _removeAttribute(name, currentNode); continue; } /* Did the hooks approve of the attribute? */ if (hookEvent.forceKeepAttr) { continue; } /* Did the hooks approve of the attribute? */ if (!hookEvent.keepAttr) { _removeAttribute(name, currentNode); continue; } /* Work around a security issue in jQuery 3.0 */ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) { _removeAttribute(name, currentNode); continue; } /* Sanitize attribute content to be template-safe */ if (SAFE_FOR_TEMPLATES) { arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { value = stringReplace(value, expr, ' '); }); } /* Is `value` valid for this attribute? */ const lcTag = transformCaseFunc(currentNode.nodeName); if (!_isValidAttribute(lcTag, lcName, value)) { _removeAttribute(name, currentNode); continue; } /* Handle attributes that require Trusted Types */ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') { if (namespaceURI) ; else { switch (trustedTypes.getAttributeType(lcTag, lcName)) { case 'TrustedHTML': { value = trustedTypesPolicy.createHTML(value); break; } case 'TrustedScriptURL': { value = trustedTypesPolicy.createScriptURL(value); break; } } } } /* Handle invalid data-* attribute set by try-catching it */ if (value !== initValue) { try { if (namespaceURI) { currentNode.setAttributeNS(namespaceURI, name, value); } else { /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ currentNode.setAttribute(name, value); } if (_isClobbered(currentNode)) { _forceRemove(currentNode); } else { arrayPop(DOMPurify.removed); } } catch (_) { _removeAttribute(name, currentNode); } } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null); }; /** * _sanitizeShadowDOM * * @param fragment to iterate over recursively */ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) { let shadowNode = null; const shadowIterator = _createNodeIterator(fragment); /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null); while (shadowNode = shadowIterator.nextNode()) { /* Execute a hook if present */ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null); /* Sanitize tags and elements */ _sanitizeElements(shadowNode); /* Check attributes next */ _sanitizeAttributes(shadowNode); /* Deep shadow DOM detected */ if (shadowNode.content instanceof DocumentFragment) { _sanitizeShadowDOM2(shadowNode.content); } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null); }; // eslint-disable-next-line complexity DOMPurify.sanitize = function (dirty) { let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; let body = null; let importedNode = null; let currentNode = null; let returnNode = null; /* Make sure we have a string to sanitize. DO NOT return early, as this will return the wrong type if the user has requested a DOM object rather than a string */ IS_EMPTY_INPUT = !dirty; if (IS_EMPTY_INPUT) { dirty = ''; } /* Stringify, in case dirty is an object */ if (typeof dirty !== 'string' && !_isNode(dirty)) { if (typeof dirty.toString === 'function') { dirty = dirty.toString(); if (typeof dirty !== 'string') { throw typeErrorCreate('dirty is not a string, aborting'); } } else { throw typeErrorCreate('toString is not a function'); } } /* Return dirty HTML if DOMPurify cannot run */ if (!DOMPurify.isSupported) { return dirty; } /* Assign config vars */ if (!SET_CONFIG) { _parseConfig(cfg); } /* Clean up removed elements */ DOMPurify.removed = []; /* Check if dirty is correctly typed for IN_PLACE */ if (typeof dirty === 'string') { IN_PLACE = false; } if (IN_PLACE) { /* Do some early pre-sanitization to avoid unsafe root nodes */ if (dirty.nodeName) { const tagName = transformCaseFunc(dirty.nodeName); if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place'); } } } else if (dirty instanceof Node) { /* If dirty is a DOM element, append to an empty document to avoid elements being stripped by the parser */ body = _initDocument(''); importedNode = body.ownerDocument.importNode(dirty, true); if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') { /* Node is already a body, use as is */ body = importedNode; } else if (importedNode.nodeName === 'HTML') { body = importedNode; } else { // eslint-disable-next-line unicorn/prefer-dom-node-append body.appendChild(importedNode); } } else { /* Exit directly if we have nothing to do */ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes dirty.indexOf('<') === -1) { return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; } /* Initialize the document to work on */ body = _initDocument(dirty); /* Check we have a DOM node from the data */ if (!body) { return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; } } /* Remove first element node (ours) if FORCE_BODY is set */ if (body && FORCE_BODY) { _forceRemove(body.firstChild); } /* Get node iterator */ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body); /* Now start iterating over the created document */ while (currentNode = nodeIterator.nextNode()) { /* Sanitize tags and elements */ _sanitizeElements(currentNode); /* Check attributes next */ _sanitizeAttributes(currentNode); /* Shadow DOM detected, sanitize it */ if (currentNode.content instanceof DocumentFragment) { _sanitizeShadowDOM2(currentNode.content); } } /* If we sanitized `dirty` in-place, return it. */ if (IN_PLACE) { return dirty; } /* Return sanitized string or DOM */ if (RETURN_DOM) { if (RETURN_DOM_FRAGMENT) { returnNode = createDocumentFragment.call(body.ownerDocument); while (body.firstChild) { // eslint-disable-next-line unicorn/prefer-dom-node-append returnNode.appendChild(body.firstChild); } } else { returnNode = body; } if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) { /* AdoptNode() is not used because internal state is not reset (e.g. the past names map of a HTMLFormElement), this is safe in theory but we would rather not risk another attack vector. The state that is cloned by importNode() is explicitly defined by the specs. */ returnNode = importNode.call(originalDocument, returnNode, true); } return returnNode; } let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; /* Serialize doctype if allowed */ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { serializedHTML = '\n' + serializedHTML; } /* Sanitize final string template-safe */ if (SAFE_FOR_TEMPLATES) { arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { serializedHTML = stringReplace(serializedHTML, expr, ' '); }); } return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; }; DOMPurify.setConfig = function () { let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _parseConfig(cfg); SET_CONFIG = true; }; DOMPurify.clearConfig = function () { CONFIG = null; SET_CONFIG = false; }; DOMPurify.isValidAttribute = function (tag, attr, value) { /* Initialize shared config vars if necessary. */ if (!CONFIG) { _parseConfig({}); } const lcTag = transformCaseFunc(tag); const lcName = transformCaseFunc(attr); return _isValidAttribute(lcTag, lcName, value); }; DOMPurify.addHook = function (entryPoint, hookFunction) { if (typeof hookFunction !== 'function') { return; } arrayPush(hooks[entryPoint], hookFunction); }; DOMPurify.removeHook = function (entryPoint, hookFunction) { if (hookFunction !== undefined) { const index = arrayLastIndexOf(hooks[entryPoint], hookFunction); return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0]; } return arrayPop(hooks[entryPoint]); }; DOMPurify.removeHooks = function (entryPoint) { hooks[entryPoint] = []; }; DOMPurify.removeAllHooks = function () { hooks = _createHooksMap(); }; return DOMPurify; } var purify = createDOMPurify(); module.exports = purify; //# sourceMappingURL=purify.cjs.js.map ================================================ FILE: dist/purify.es.d.mts ================================================ /*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */ import { TrustedTypePolicy, TrustedHTML, TrustedTypesWindow } from 'trusted-types/lib/index.js'; /** * Configuration to control DOMPurify behavior. */ interface Config { /** * Extend the existing array of allowed attributes. * Can be an array of attribute names, or a function that receives * the attribute name and tag name to determine if the attribute is allowed. */ ADD_ATTR?: string[] | ((attributeName: string, tagName: string) => boolean) | undefined; /** * Extend the existing array of elements that can use Data URIs. */ ADD_DATA_URI_TAGS?: string[] | undefined; /** * Extend the existing array of allowed tags. * Can be an array of tag names, or a function that receives * the tag name to determine if the tag is allowed. */ ADD_TAGS?: string[] | ((tagName: string) => boolean) | undefined; /** * Extend the existing array of elements that are safe for URI-like values (be careful, XSS risk). */ ADD_URI_SAFE_ATTR?: string[] | undefined; /** * Allow ARIA attributes, leave other safe HTML as is (default is true). */ ALLOW_ARIA_ATTR?: boolean | undefined; /** * Allow HTML5 data attributes, leave other safe HTML as is (default is true). */ ALLOW_DATA_ATTR?: boolean | undefined; /** * Allow external protocol handlers in URL attributes (default is false, be careful, XSS risk). * By default only `http`, `https`, `ftp`, `ftps`, `tel`, `mailto`, `callto`, `sms`, `cid` and `xmpp` are allowed. */ ALLOW_UNKNOWN_PROTOCOLS?: boolean | undefined; /** * Decide if self-closing tags in attributes are allowed. * Usually removed due to a mXSS issue in jQuery 3.0. */ ALLOW_SELF_CLOSE_IN_ATTR?: boolean | undefined; /** * Allow only specific attributes. */ ALLOWED_ATTR?: string[] | undefined; /** * Allow only specific elements. */ ALLOWED_TAGS?: string[] | undefined; /** * Allow only specific namespaces. Defaults to: * - `http://www.w3.org/1999/xhtml` * - `http://www.w3.org/2000/svg` * - `http://www.w3.org/1998/Math/MathML` */ ALLOWED_NAMESPACES?: string[] | undefined; /** * Allow specific protocols handlers in URL attributes via regex (be careful, XSS risk). * Default RegExp: * ``` * /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i; * ``` */ ALLOWED_URI_REGEXP?: RegExp | undefined; /** * Define how custom elements are handled. */ CUSTOM_ELEMENT_HANDLING?: { /** * Regular expression or function to match to allowed elements. * Default is null (disallow any custom elements). */ tagNameCheck?: RegExp | ((tagName: string) => boolean) | null | undefined; /** * Regular expression or function to match to allowed attributes. * Default is null (disallow any attributes not on the allow list). */ attributeNameCheck?: RegExp | ((attributeName: string, tagName?: string) => boolean) | null | undefined; /** * Allow custom elements derived from built-ins if they pass `tagNameCheck`. Default is false. */ allowCustomizedBuiltInElements?: boolean | undefined; }; /** * Add attributes to block-list. */ FORBID_ATTR?: string[] | undefined; /** * Add child elements to be removed when their parent is removed. */ FORBID_CONTENTS?: string[] | undefined; /** * Extend the existing or default array of forbidden content elements. */ ADD_FORBID_CONTENTS?: string[] | undefined; /** * Add elements to block-list. */ FORBID_TAGS?: string[] | undefined; /** * Glue elements like style, script or others to `document.body` and prevent unintuitive browser behavior in several edge-cases (default is false). */ FORCE_BODY?: boolean | undefined; /** * Map of non-standard HTML element names to support. Map to true to enable support. For example: * * ``` * HTML_INTEGRATION_POINTS: { foreignobject: true } * ``` */ HTML_INTEGRATION_POINTS?: Record | undefined; /** * Sanitize a node "in place", which is much faster depending on how you use DOMPurify. */ IN_PLACE?: boolean | undefined; /** * Keep an element's content when the element is removed (default is true). */ KEEP_CONTENT?: boolean | undefined; /** * Map of MathML element names to support. Map to true to enable support. For example: * * ``` * MATHML_TEXT_INTEGRATION_POINTS: { mtext: true } * ``` */ MATHML_TEXT_INTEGRATION_POINTS?: Record | undefined; /** * Change the default namespace from HTML to something different. */ NAMESPACE?: string | undefined; /** * Change the parser type so sanitized data is treated as XML and not as HTML, which is the default. */ PARSER_MEDIA_TYPE?: DOMParserSupportedType | undefined; /** * Return a DOM `DocumentFragment` instead of an HTML string (default is false). */ RETURN_DOM_FRAGMENT?: boolean | undefined; /** * Return a DOM `HTMLBodyElement` instead of an HTML string (default is false). */ RETURN_DOM?: boolean | undefined; /** * Return a TrustedHTML object instead of a string if possible. */ RETURN_TRUSTED_TYPE?: boolean | undefined; /** * Strip `{{ ... }}`, `${ ... }` and `<% ... %>` to make output safe for template systems. * Be careful please, this mode is not recommended for production usage. * Allowing template parsing in user-controlled HTML is not advised at all. * Only use this mode if there is really no alternative. */ SAFE_FOR_TEMPLATES?: boolean | undefined; /** * Change how e.g. comments containing risky HTML characters are treated. * Be very careful, this setting should only be set to `false` if you really only handle * HTML and nothing else, no SVG, MathML or the like. * Otherwise, changing from `true` to `false` will lead to XSS in this or some other way. */ SAFE_FOR_XML?: boolean | undefined; /** * Use DOM Clobbering protection on output (default is true, handle with care, minor XSS risks here). */ SANITIZE_DOM?: boolean | undefined; /** * Enforce strict DOM Clobbering protection via namespace isolation (default is false). * When enabled, isolates the namespace of named properties (i.e., `id` and `name` attributes) * from JS variables by prefixing them with the string `user-content-` */ SANITIZE_NAMED_PROPS?: boolean | undefined; /** * Supplied policy must define `createHTML` and `createScriptURL`. */ TRUSTED_TYPES_POLICY?: TrustedTypePolicy | undefined; /** * Controls categories of allowed elements. * * Note that the `USE_PROFILES` setting will override the `ALLOWED_TAGS` setting * so don't use them together. */ USE_PROFILES?: false | UseProfilesConfig | undefined; /** * Return entire document including tags (default is false). */ WHOLE_DOCUMENT?: boolean | undefined; } /** * Defines categories of allowed elements. */ interface UseProfilesConfig { /** * Allow all safe MathML elements. */ mathMl?: boolean | undefined; /** * Allow all safe SVG elements. */ svg?: boolean | undefined; /** * Allow all save SVG Filters. */ svgFilters?: boolean | undefined; /** * Allow all safe HTML elements. */ html?: boolean | undefined; } declare const _default: DOMPurify; interface DOMPurify { /** * Creates a DOMPurify instance using the given window-like object. Defaults to `window`. */ (root?: WindowLike): DOMPurify; /** * Version label, exposed for easier checks * if DOMPurify is up to date or not */ version: string; /** * Array of elements that DOMPurify removed during sanitation. * Empty if nothing was removed. */ removed: Array; /** * Expose whether this browser supports running the full DOMPurify. */ isSupported: boolean; /** * Set the configuration once. * * @param cfg configuration object */ setConfig(cfg?: Config): void; /** * Removes the configuration. */ clearConfig(): void; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized TrustedHTML. */ sanitize(dirty: string | Node, cfg: Config & { RETURN_TRUSTED_TYPE: true; }): TrustedHTML; /** * Provides core sanitation functionality. * * @param dirty DOM node * @param cfg object * @returns Sanitized DOM node. */ sanitize(dirty: Node, cfg: Config & { IN_PLACE: true; }): Node; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized DOM node. */ sanitize(dirty: string | Node, cfg: Config & { RETURN_DOM: true; }): Node; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized document fragment. */ sanitize(dirty: string | Node, cfg: Config & { RETURN_DOM_FRAGMENT: true; }): DocumentFragment; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized string. */ sanitize(dirty: string | Node, cfg?: Config): string; /** * Checks if an attribute value is valid. * Uses last set config, if any. Otherwise, uses config defaults. * * @param tag Tag name of containing element. * @param attr Attribute name. * @param value Attribute value. * @returns Returns true if `value` is valid. Otherwise, returns false. */ isValidAttribute(tag: string, attr: string, value: string): boolean; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: BasicHookName, hookFunction: NodeHook): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: ElementHookName, hookFunction: ElementHook): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: DocumentFragmentHookName, hookFunction: DocumentFragmentHook): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: 'uponSanitizeElement', hookFunction: UponSanitizeElementHook): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: 'uponSanitizeAttribute', hookFunction: UponSanitizeAttributeHook): void; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook(entryPoint: BasicHookName, hookFunction?: NodeHook): NodeHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook(entryPoint: ElementHookName, hookFunction?: ElementHook): ElementHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook(entryPoint: DocumentFragmentHookName, hookFunction?: DocumentFragmentHook): DocumentFragmentHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook(entryPoint: 'uponSanitizeElement', hookFunction?: UponSanitizeElementHook): UponSanitizeElementHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook(entryPoint: 'uponSanitizeAttribute', hookFunction?: UponSanitizeAttributeHook): UponSanitizeAttributeHook | undefined; /** * Removes all DOMPurify hooks at a given entryPoint * * @param entryPoint entry point for the hooks to remove */ removeHooks(entryPoint: HookName): void; /** * Removes all DOMPurify hooks. */ removeAllHooks(): void; } /** * An element removed by DOMPurify. */ interface RemovedElement { /** * The element that was removed. */ element: Node; } /** * An element removed by DOMPurify. */ interface RemovedAttribute { /** * The attribute that was removed. */ attribute: Attr | null; /** * The element that the attribute was removed. */ from: Node; } type BasicHookName = 'beforeSanitizeElements' | 'afterSanitizeElements' | 'uponSanitizeShadowNode'; type ElementHookName = 'beforeSanitizeAttributes' | 'afterSanitizeAttributes'; type DocumentFragmentHookName = 'beforeSanitizeShadowDOM' | 'afterSanitizeShadowDOM'; type UponSanitizeElementHookName = 'uponSanitizeElement'; type UponSanitizeAttributeHookName = 'uponSanitizeAttribute'; type HookName = BasicHookName | ElementHookName | DocumentFragmentHookName | UponSanitizeElementHookName | UponSanitizeAttributeHookName; type NodeHook = (this: DOMPurify, currentNode: Node, hookEvent: null, config: Config) => void; type ElementHook = (this: DOMPurify, currentNode: Element, hookEvent: null, config: Config) => void; type DocumentFragmentHook = (this: DOMPurify, currentNode: DocumentFragment, hookEvent: null, config: Config) => void; type UponSanitizeElementHook = (this: DOMPurify, currentNode: Node, hookEvent: UponSanitizeElementHookEvent, config: Config) => void; type UponSanitizeAttributeHook = (this: DOMPurify, currentNode: Element, hookEvent: UponSanitizeAttributeHookEvent, config: Config) => void; interface UponSanitizeElementHookEvent { tagName: string; allowedTags: Record; } interface UponSanitizeAttributeHookEvent { attrName: string; attrValue: string; keepAttr: boolean; allowedAttributes: Record; forceKeepAttr: boolean | undefined; } /** * A `Window`-like object containing the properties and types that DOMPurify requires. */ type WindowLike = Pick & { document?: Document; MozNamedAttrMap?: typeof window.NamedNodeMap; } & Pick; export { _default as default }; export type { Config, DOMPurify, DocumentFragmentHook, ElementHook, HookName, NodeHook, RemovedAttribute, RemovedElement, UponSanitizeAttributeHook, UponSanitizeAttributeHookEvent, UponSanitizeElementHook, UponSanitizeElementHookEvent, WindowLike }; ================================================ FILE: dist/purify.es.mjs ================================================ /*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */ const { entries, setPrototypeOf, isFrozen, getPrototypeOf, getOwnPropertyDescriptor } = Object; let { freeze, seal, create } = Object; // eslint-disable-line import/no-mutable-exports let { apply, construct } = typeof Reflect !== 'undefined' && Reflect; if (!freeze) { freeze = function freeze(x) { return x; }; } if (!seal) { seal = function seal(x) { return x; }; } if (!apply) { apply = function apply(func, thisArg) { for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } return func.apply(thisArg, args); }; } if (!construct) { construct = function construct(Func) { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } return new Func(...args); }; } const arrayForEach = unapply(Array.prototype.forEach); const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf); const arrayPop = unapply(Array.prototype.pop); const arrayPush = unapply(Array.prototype.push); const arraySplice = unapply(Array.prototype.splice); const stringToLowerCase = unapply(String.prototype.toLowerCase); const stringToString = unapply(String.prototype.toString); const stringMatch = unapply(String.prototype.match); const stringReplace = unapply(String.prototype.replace); const stringIndexOf = unapply(String.prototype.indexOf); const stringTrim = unapply(String.prototype.trim); const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty); const regExpTest = unapply(RegExp.prototype.test); const typeErrorCreate = unconstruct(TypeError); /** * Creates a new function that calls the given function with a specified thisArg and arguments. * * @param func - The function to be wrapped and called. * @returns A new function that calls the given function with a specified thisArg and arguments. */ function unapply(func) { return function (thisArg) { if (thisArg instanceof RegExp) { thisArg.lastIndex = 0; } for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { args[_key3 - 1] = arguments[_key3]; } return apply(func, thisArg, args); }; } /** * Creates a new function that constructs an instance of the given constructor function with the provided arguments. * * @param func - The constructor function to be wrapped and called. * @returns A new function that constructs an instance of the given constructor function with the provided arguments. */ function unconstruct(Func) { return function () { for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { args[_key4] = arguments[_key4]; } return construct(Func, args); }; } /** * Add properties to a lookup table * * @param set - The set to which elements will be added. * @param array - The array containing elements to be added to the set. * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set. * @returns The modified set with added elements. */ function addToSet(set, array) { let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase; if (setPrototypeOf) { // Make 'in' and truthy checks like Boolean(set.constructor) // independent of any properties defined on Object.prototype. // Prevent prototype setters from intercepting set as a this value. setPrototypeOf(set, null); } let l = array.length; while (l--) { let element = array[l]; if (typeof element === 'string') { const lcElement = transformCaseFunc(element); if (lcElement !== element) { // Config presets (e.g. tags.js, attrs.js) are immutable. if (!isFrozen(array)) { array[l] = lcElement; } element = lcElement; } } set[element] = true; } return set; } /** * Clean up an array to harden against CSPP * * @param array - The array to be cleaned. * @returns The cleaned version of the array */ function cleanArray(array) { for (let index = 0; index < array.length; index++) { const isPropertyExist = objectHasOwnProperty(array, index); if (!isPropertyExist) { array[index] = null; } } return array; } /** * Shallow clone an object * * @param object - The object to be cloned. * @returns A new object that copies the original. */ function clone(object) { const newObject = create(null); for (const [property, value] of entries(object)) { const isPropertyExist = objectHasOwnProperty(object, property); if (isPropertyExist) { if (Array.isArray(value)) { newObject[property] = cleanArray(value); } else if (value && typeof value === 'object' && value.constructor === Object) { newObject[property] = clone(value); } else { newObject[property] = value; } } } return newObject; } /** * This method automatically checks if the prop is function or getter and behaves accordingly. * * @param object - The object to look up the getter function in its prototype chain. * @param prop - The property name for which to find the getter function. * @returns The getter function found in the prototype chain or a fallback function. */ function lookupGetter(object, prop) { while (object !== null) { const desc = getOwnPropertyDescriptor(object, prop); if (desc) { if (desc.get) { return unapply(desc.get); } if (typeof desc.value === 'function') { return unapply(desc.value); } } object = getPrototypeOf(object); } function fallbackValue() { return null; } return fallbackValue; } const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); // List of SVG elements that are disallowed by default. // We still need to know them so that we can do namespace // checks properly in case one wants to add them to // allow-list. const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); // Similarly to SVG, we want to know all MathML elements, // even those that we disallow by default. const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); const text = freeze(['#text']); const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']); const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); // eslint-disable-next-line unicorn/better-regex const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape ); const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex ); const DOCTYPE_NAME = seal(/^html$/i); const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i); var EXPRESSIONS = /*#__PURE__*/Object.freeze({ __proto__: null, ARIA_ATTR: ARIA_ATTR, ATTR_WHITESPACE: ATTR_WHITESPACE, CUSTOM_ELEMENT: CUSTOM_ELEMENT, DATA_ATTR: DATA_ATTR, DOCTYPE_NAME: DOCTYPE_NAME, ERB_EXPR: ERB_EXPR, IS_ALLOWED_URI: IS_ALLOWED_URI, IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA, MUSTACHE_EXPR: MUSTACHE_EXPR, TMPLIT_EXPR: TMPLIT_EXPR }); /* eslint-disable @typescript-eslint/indent */ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType const NODE_TYPE = { element: 1, attribute: 2, text: 3, cdataSection: 4, entityReference: 5, // Deprecated entityNode: 6, // Deprecated progressingInstruction: 7, comment: 8, document: 9, documentType: 10, documentFragment: 11, notation: 12 // Deprecated }; const getGlobal = function getGlobal() { return typeof window === 'undefined' ? null : window; }; /** * Creates a no-op policy for internal use only. * Don't export this function outside this module! * @param trustedTypes The policy factory. * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix). * @return The policy created (or null, if Trusted Types * are not supported or creating the policy failed). */ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) { if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') { return null; } // Allow the callers to control the unique policy name // by adding a data-tt-policy-suffix to the script element with the DOMPurify. // Policy creation with duplicate names throws in Trusted Types. let suffix = null; const ATTR_NAME = 'data-tt-policy-suffix'; if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) { suffix = purifyHostElement.getAttribute(ATTR_NAME); } const policyName = 'dompurify' + (suffix ? '#' + suffix : ''); try { return trustedTypes.createPolicy(policyName, { createHTML(html) { return html; }, createScriptURL(scriptUrl) { return scriptUrl; } }); } catch (_) { // Policy creation failed (most likely another DOMPurify script has // already run). Skip creating the policy, as this will only cause errors // if TT are enforced. console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); return null; } }; const _createHooksMap = function _createHooksMap() { return { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] }; }; function createDOMPurify() { let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); const DOMPurify = root => createDOMPurify(root); DOMPurify.version = '3.3.3'; DOMPurify.removed = []; if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) { // Not running in a browser, provide a factory function // so that you can pass your own Window DOMPurify.isSupported = false; return DOMPurify; } let { document } = window; const originalDocument = document; const currentScript = originalDocument.currentScript; const { DocumentFragment, HTMLTemplateElement, Node, Element, NodeFilter, NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap, HTMLFormElement, DOMParser, trustedTypes } = window; const ElementPrototype = Element.prototype; const cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); const remove = lookupGetter(ElementPrototype, 'remove'); const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); const getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a // new document created via createHTMLDocument. As per the spec // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) // a new empty registry is used when creating a template contents owner // document, so we use that as our parent document to ensure nothing // is inherited. if (typeof HTMLTemplateElement === 'function') { const template = document.createElement('template'); if (template.content && template.content.ownerDocument) { document = template.content.ownerDocument; } } let trustedTypesPolicy; let emptyHTML = ''; const { implementation, createNodeIterator, createDocumentFragment, getElementsByTagName } = document; const { importNode } = originalDocument; let hooks = _createHooksMap(); /** * Expose whether this browser supports running the full DOMPurify. */ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined; const { MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR, DATA_ATTR, ARIA_ATTR, IS_SCRIPT_OR_DATA, ATTR_WHITESPACE, CUSTOM_ELEMENT } = EXPRESSIONS; let { IS_ALLOWED_URI: IS_ALLOWED_URI$1 } = EXPRESSIONS; /** * We consider the elements and attributes below to be safe. Ideally * don't add any new ones but feel free to remove unwanted ones. */ /* allowed element names */ let ALLOWED_TAGS = null; const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]); /* Allowed attribute names */ let ALLOWED_ATTR = null; const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]); /* * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements. * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements) * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list) * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`. */ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, { tagNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, attributeNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, allowCustomizedBuiltInElements: { writable: true, configurable: false, enumerable: true, value: false } })); /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ let FORBID_TAGS = null; /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ let FORBID_ATTR = null; /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, { tagCheck: { writable: true, configurable: false, enumerable: true, value: null }, attributeCheck: { writable: true, configurable: false, enumerable: true, value: null } })); /* Decide if ARIA attributes are okay */ let ALLOW_ARIA_ATTR = true; /* Decide if custom data attributes are okay */ let ALLOW_DATA_ATTR = true; /* Decide if unknown protocols are okay */ let ALLOW_UNKNOWN_PROTOCOLS = false; /* Decide if self-closing tags in attributes are allowed. * Usually removed due to a mXSS issue in jQuery 3.0 */ let ALLOW_SELF_CLOSE_IN_ATTR = true; /* Output should be safe for common template engines. * This means, DOMPurify removes data attributes, mustaches and ERB */ let SAFE_FOR_TEMPLATES = false; /* Output should be safe even for XML used within HTML and alike. * This means, DOMPurify removes comments when containing risky content. */ let SAFE_FOR_XML = true; /* Decide if document with ... should be returned */ let WHOLE_DOCUMENT = false; /* Track whether config is already set on this instance of DOMPurify. */ let SET_CONFIG = false; /* Decide if all elements (e.g. style, script) must be children of * document.body. By default, browsers might move them to document.head */ let FORCE_BODY = false; /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html * string (or a TrustedHTML object if Trusted Types are supported). * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead */ let RETURN_DOM = false; /* Decide if a DOM `DocumentFragment` should be returned, instead of a html * string (or a TrustedHTML object if Trusted Types are supported) */ let RETURN_DOM_FRAGMENT = false; /* Try to return a Trusted Type object instead of a string, return a string in * case Trusted Types are not supported */ let RETURN_TRUSTED_TYPE = false; /* Output should be free from DOM clobbering attacks? * This sanitizes markups named with colliding, clobberable built-in DOM APIs. */ let SANITIZE_DOM = true; /* Achieve full DOM Clobbering protection by isolating the namespace of named * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules. * * HTML/DOM spec rules that enable DOM Clobbering: * - Named Access on Window (§7.3.3) * - DOM Tree Accessors (§3.1.5) * - Form Element Parent-Child Relations (§4.10.3) * - Iframe srcdoc / Nested WindowProxies (§4.8.5) * - HTMLCollection (§4.2.10.2) * * Namespace isolation is implemented by prefixing `id` and `name` attributes * with a constant string, i.e., `user-content-` */ let SANITIZE_NAMED_PROPS = false; const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-'; /* Keep element content when removing element? */ let KEEP_CONTENT = true; /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead * of importing it into a new Document and returning a sanitized copy */ let IN_PLACE = false; /* Allow usage of profiles like html, svg and mathMl */ let USE_PROFILES = {}; /* Tags to ignore content of when KEEP_CONTENT is true */ let FORBID_CONTENTS = null; const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); /* Tags that are safe for data: URIs */ let DATA_URI_TAGS = null; const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); /* Attributes safe for values like "javascript:" */ let URI_SAFE_ATTRIBUTES = null; const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; /* Document namespace */ let NAMESPACE = HTML_NAMESPACE; let IS_EMPTY_INPUT = false; /* Allowed XHTML+XML namespaces */ let ALLOWED_NAMESPACES = null; const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString); let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']); // Certain elements are allowed in both SVG and HTML // namespace. We need to specify them explicitly // so that they don't get erroneously deleted from // HTML namespace. const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']); /* Parsing of strict XHTML documents */ let PARSER_MEDIA_TYPE = null; const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; const DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; let transformCaseFunc = null; /* Keep a reference to config to pass to hooks */ let CONFIG = null; /* Ideally, do not touch anything below this line */ /* ______________________________________________ */ const formElement = document.createElement('form'); const isRegexOrFunction = function isRegexOrFunction(testValue) { return testValue instanceof RegExp || testValue instanceof Function; }; /** * _parseConfig * * @param cfg optional config literal */ // eslint-disable-next-line complexity const _parseConfig = function _parseConfig() { let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; if (CONFIG && CONFIG === cfg) { return; } /* Shield configuration object from tampering */ if (!cfg || typeof cfg !== 'object') { cfg = {}; } /* Shield configuration object from prototype pollution */ cfg = clone(cfg); PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase; /* Set configuration parameters */ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS; ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR; ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES; URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES; DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS; FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS; FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({}); FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({}); USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false; ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false RETURN_DOM = cfg.RETURN_DOM || false; // Default false RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false FORCE_BODY = cfg.FORCE_BODY || false; // Default false SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true IN_PLACE = cfg.IN_PLACE || false; // Default false IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI; NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS; HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS; CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {}; if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; } if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) { CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck; } if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') { CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements; } if (SAFE_FOR_TEMPLATES) { ALLOW_DATA_ATTR = false; } if (RETURN_DOM_FRAGMENT) { RETURN_DOM = true; } /* Parse profile info */ if (USE_PROFILES) { ALLOWED_TAGS = addToSet({}, text); ALLOWED_ATTR = create(null); if (USE_PROFILES.html === true) { addToSet(ALLOWED_TAGS, html$1); addToSet(ALLOWED_ATTR, html); } if (USE_PROFILES.svg === true) { addToSet(ALLOWED_TAGS, svg$1); addToSet(ALLOWED_ATTR, svg); addToSet(ALLOWED_ATTR, xml); } if (USE_PROFILES.svgFilters === true) { addToSet(ALLOWED_TAGS, svgFilters); addToSet(ALLOWED_ATTR, svg); addToSet(ALLOWED_ATTR, xml); } if (USE_PROFILES.mathMl === true) { addToSet(ALLOWED_TAGS, mathMl$1); addToSet(ALLOWED_ATTR, mathMl); addToSet(ALLOWED_ATTR, xml); } } /* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */ if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) { EXTRA_ELEMENT_HANDLING.tagCheck = null; } if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) { EXTRA_ELEMENT_HANDLING.attributeCheck = null; } /* Merge configuration parameters */ if (cfg.ADD_TAGS) { if (typeof cfg.ADD_TAGS === 'function') { EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS; } else { if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { ALLOWED_TAGS = clone(ALLOWED_TAGS); } addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc); } } if (cfg.ADD_ATTR) { if (typeof cfg.ADD_ATTR === 'function') { EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR; } else { if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { ALLOWED_ATTR = clone(ALLOWED_ATTR); } addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc); } } if (cfg.ADD_URI_SAFE_ATTR) { addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc); } if (cfg.FORBID_CONTENTS) { if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { FORBID_CONTENTS = clone(FORBID_CONTENTS); } addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc); } if (cfg.ADD_FORBID_CONTENTS) { if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { FORBID_CONTENTS = clone(FORBID_CONTENTS); } addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc); } /* Add #text in case KEEP_CONTENT is set to true */ if (KEEP_CONTENT) { ALLOWED_TAGS['#text'] = true; } /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ if (WHOLE_DOCUMENT) { addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); } /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ if (ALLOWED_TAGS.table) { addToSet(ALLOWED_TAGS, ['tbody']); delete FORBID_TAGS.tbody; } if (cfg.TRUSTED_TYPES_POLICY) { if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') { throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); } if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') { throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); } // Overwrite existing TrustedTypes policy. trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; // Sign local variables required by `sanitize`. emptyHTML = trustedTypesPolicy.createHTML(''); } else { // Uninitialized policy, attempt to initialize the internal dompurify policy. if (trustedTypesPolicy === undefined) { trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript); } // If creating the internal policy succeeded sign internal variables. if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') { emptyHTML = trustedTypesPolicy.createHTML(''); } } // Prevent further manipulation of configuration. // Not available in IE8, Safari 5, etc. if (freeze) { freeze(cfg); } CONFIG = cfg; }; /* Keep track of all possible SVG and MathML tags * so that we can perform the namespace checks * correctly. */ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]); const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]); /** * @param element a DOM element whose namespace is being checked * @returns Return false if the element has a * namespace that a spec-compliant parser would never * return. Return true otherwise. */ const _checkValidNamespace = function _checkValidNamespace(element) { let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode // can be null. We just simulate parent in this case. if (!parent || !parent.tagName) { parent = { namespaceURI: NAMESPACE, tagName: 'template' }; } const tagName = stringToLowerCase(element.tagName); const parentTagName = stringToLowerCase(parent.tagName); if (!ALLOWED_NAMESPACES[element.namespaceURI]) { return false; } if (element.namespaceURI === SVG_NAMESPACE) { // The only way to switch from HTML namespace to SVG // is via . If it happens via any other tag, then // it should be killed. if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === 'svg'; } // The only way to switch from MathML to SVG is via` // svg if parent is either or MathML // text integration points. if (parent.namespaceURI === MATHML_NAMESPACE) { return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); } // We only allow elements that are defined in SVG // spec. All others are disallowed in SVG namespace. return Boolean(ALL_SVG_TAGS[tagName]); } if (element.namespaceURI === MATHML_NAMESPACE) { // The only way to switch from HTML namespace to MathML // is via . If it happens via any other tag, then // it should be killed. if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === 'math'; } // The only way to switch from SVG to MathML is via // and HTML integration points if (parent.namespaceURI === SVG_NAMESPACE) { return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; } // We only allow elements that are defined in MathML // spec. All others are disallowed in MathML namespace. return Boolean(ALL_MATHML_TAGS[tagName]); } if (element.namespaceURI === HTML_NAMESPACE) { // The only way to switch from SVG to HTML is via // HTML integration points, and from MathML to HTML // is via MathML text integration points if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { return false; } if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { return false; } // We disallow tags that are specific for MathML // or SVG and should never appear in HTML namespace return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); } // For XHTML and XML documents that support custom namespaces if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) { return true; } // The code should never reach this place (this means // that the element somehow got namespace that is not // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES). // Return false just in case. return false; }; /** * _forceRemove * * @param node a DOM node */ const _forceRemove = function _forceRemove(node) { arrayPush(DOMPurify.removed, { element: node }); try { // eslint-disable-next-line unicorn/prefer-dom-node-remove getParentNode(node).removeChild(node); } catch (_) { remove(node); } }; /** * _removeAttribute * * @param name an Attribute name * @param element a DOM node */ const _removeAttribute = function _removeAttribute(name, element) { try { arrayPush(DOMPurify.removed, { attribute: element.getAttributeNode(name), from: element }); } catch (_) { arrayPush(DOMPurify.removed, { attribute: null, from: element }); } element.removeAttribute(name); // We void attribute values for unremovable "is" attributes if (name === 'is') { if (RETURN_DOM || RETURN_DOM_FRAGMENT) { try { _forceRemove(element); } catch (_) {} } else { try { element.setAttribute(name, ''); } catch (_) {} } } }; /** * _initDocument * * @param dirty - a string of dirty markup * @return a DOM, filled with the dirty markup */ const _initDocument = function _initDocument(dirty) { /* Create a HTML document */ let doc = null; let leadingWhitespace = null; if (FORCE_BODY) { dirty = '' + dirty; } else { /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ const matches = stringMatch(dirty, /^[\r\n\t ]+/); leadingWhitespace = matches && matches[0]; } if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) { // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict) dirty = '' + dirty + ''; } const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; /* * Use the DOMParser API by default, fallback later if needs be * DOMParser not work for svg when has multiple root element. */ if (NAMESPACE === HTML_NAMESPACE) { try { doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); } catch (_) {} } /* Use createHTMLDocument in case DOMParser is not available */ if (!doc || !doc.documentElement) { doc = implementation.createDocument(NAMESPACE, 'template', null); try { doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload; } catch (_) { // Syntax error if dirtyPayload is invalid xml } } const body = doc.body || doc.documentElement; if (dirty && leadingWhitespace) { body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null); } /* Work on whole document or just its body */ if (NAMESPACE === HTML_NAMESPACE) { return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; } return WHOLE_DOCUMENT ? doc.documentElement : body; }; /** * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. * * @param root The root element or node to start traversing on. * @return The created NodeIterator */ const _createNodeIterator = function _createNodeIterator(root) { return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null); }; /** * _isClobbered * * @param element element to check for clobbering attacks * @return true if clobbered, false if safe */ const _isClobbered = function _isClobbered(element) { return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function'); }; /** * Checks whether the given object is a DOM node. * * @param value object to check whether it's a DOM node * @return true is object is a DOM node */ const _isNode = function _isNode(value) { return typeof Node === 'function' && value instanceof Node; }; function _executeHooks(hooks, currentNode, data) { arrayForEach(hooks, hook => { hook.call(DOMPurify, currentNode, data, CONFIG); }); } /** * _sanitizeElements * * @protect nodeName * @protect textContent * @protect removeChild * @param currentNode to check for permission to exist * @return true if node was killed, false if left alive */ const _sanitizeElements = function _sanitizeElements(currentNode) { let content = null; /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeElements, currentNode, null); /* Check if element is clobbered or can clobber */ if (_isClobbered(currentNode)) { _forceRemove(currentNode); return true; } /* Now let's check the element's type and name */ const tagName = transformCaseFunc(currentNode.nodeName); /* Execute a hook if present */ _executeHooks(hooks.uponSanitizeElement, currentNode, { tagName, allowedTags: ALLOWED_TAGS }); /* Detect mXSS attempts abusing namespace confusion */ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) { _forceRemove(currentNode); return true; } /* Remove any occurrence of processing instructions */ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) { _forceRemove(currentNode); return true; } /* Remove any kind of possibly harmful comments */ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) { _forceRemove(currentNode); return true; } /* Remove element if anything forbids its presence */ if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) { /* Check if we have a custom element to handle */ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) { if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) { return false; } if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) { return false; } } /* Keep content except for bad-listed elements */ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { const parentNode = getParentNode(currentNode) || currentNode.parentNode; const childNodes = getChildNodes(currentNode) || currentNode.childNodes; if (childNodes && parentNode) { const childCount = childNodes.length; for (let i = childCount - 1; i >= 0; --i) { const childClone = cloneNode(childNodes[i], true); childClone.__removalCount = (currentNode.__removalCount || 0) + 1; parentNode.insertBefore(childClone, getNextSibling(currentNode)); } } } _forceRemove(currentNode); return true; } /* Check whether element has a valid namespace */ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { _forceRemove(currentNode); return true; } /* Make sure that older browsers don't get fallback-tag mXSS */ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) { _forceRemove(currentNode); return true; } /* Sanitize element content to be template-safe */ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) { /* Get the element's text content */ content = currentNode.textContent; arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { content = stringReplace(content, expr, ' '); }); if (currentNode.textContent !== content) { arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); currentNode.textContent = content; } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeElements, currentNode, null); return false; }; /** * _isValidAttribute * * @param lcTag Lowercase tag name of containing element. * @param lcName Lowercase attribute name. * @param value Attribute value. * @return Returns true if `value` is valid, otherwise false. */ // eslint-disable-next-line complexity const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */ if (FORBID_ATTR[lcName]) { return false; } /* Make sure attribute cannot clobber */ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { return false; } /* Allow valid data-* attributes: At least one character after "-" (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) We don't need to check the value; it's always URI safe. */ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || // Alternative, second condition checks if it's an `is`-attribute, AND // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else { return false; } /* Check value is safe. First, is attr inert? If so, is safe */ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) { return false; } else ; return true; }; /** * _isBasicCustomElement * checks if at least one dash is included in tagName, and it's not the first char * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name * * @param tagName name of the tag of the node to sanitize * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false. */ const _isBasicCustomElement = function _isBasicCustomElement(tagName) { return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT); }; /** * _sanitizeAttributes * * @protect attributes * @protect nodeName * @protect removeAttribute * @protect setAttribute * * @param currentNode to sanitize */ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) { /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null); const { attributes } = currentNode; /* Check if we have attributes; if not we might have a text node */ if (!attributes || _isClobbered(currentNode)) { return; } const hookEvent = { attrName: '', attrValue: '', keepAttr: true, allowedAttributes: ALLOWED_ATTR, forceKeepAttr: undefined }; let l = attributes.length; /* Go backwards over all attributes; safely remove bad ones */ while (l--) { const attr = attributes[l]; const { name, namespaceURI, value: attrValue } = attr; const lcName = transformCaseFunc(name); const initValue = attrValue; let value = name === 'value' ? initValue : stringTrim(initValue); /* Execute a hook if present */ hookEvent.attrName = lcName; hookEvent.attrValue = value; hookEvent.keepAttr = true; hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent); value = hookEvent.attrValue; /* Full DOM Clobbering protection via namespace isolation, * Prefix id and name attributes with `user-content-` */ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) { // Remove the attribute with this value _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value value = SANITIZE_NAMED_PROPS_PREFIX + value; } /* Work around a security issue with comments inside attributes */ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) { _removeAttribute(name, currentNode); continue; } /* Make sure we cannot easily use animated hrefs, even if animations are allowed */ if (lcName === 'attributename' && stringMatch(value, 'href')) { _removeAttribute(name, currentNode); continue; } /* Did the hooks approve of the attribute? */ if (hookEvent.forceKeepAttr) { continue; } /* Did the hooks approve of the attribute? */ if (!hookEvent.keepAttr) { _removeAttribute(name, currentNode); continue; } /* Work around a security issue in jQuery 3.0 */ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) { _removeAttribute(name, currentNode); continue; } /* Sanitize attribute content to be template-safe */ if (SAFE_FOR_TEMPLATES) { arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { value = stringReplace(value, expr, ' '); }); } /* Is `value` valid for this attribute? */ const lcTag = transformCaseFunc(currentNode.nodeName); if (!_isValidAttribute(lcTag, lcName, value)) { _removeAttribute(name, currentNode); continue; } /* Handle attributes that require Trusted Types */ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') { if (namespaceURI) ; else { switch (trustedTypes.getAttributeType(lcTag, lcName)) { case 'TrustedHTML': { value = trustedTypesPolicy.createHTML(value); break; } case 'TrustedScriptURL': { value = trustedTypesPolicy.createScriptURL(value); break; } } } } /* Handle invalid data-* attribute set by try-catching it */ if (value !== initValue) { try { if (namespaceURI) { currentNode.setAttributeNS(namespaceURI, name, value); } else { /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ currentNode.setAttribute(name, value); } if (_isClobbered(currentNode)) { _forceRemove(currentNode); } else { arrayPop(DOMPurify.removed); } } catch (_) { _removeAttribute(name, currentNode); } } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null); }; /** * _sanitizeShadowDOM * * @param fragment to iterate over recursively */ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) { let shadowNode = null; const shadowIterator = _createNodeIterator(fragment); /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null); while (shadowNode = shadowIterator.nextNode()) { /* Execute a hook if present */ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null); /* Sanitize tags and elements */ _sanitizeElements(shadowNode); /* Check attributes next */ _sanitizeAttributes(shadowNode); /* Deep shadow DOM detected */ if (shadowNode.content instanceof DocumentFragment) { _sanitizeShadowDOM2(shadowNode.content); } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null); }; // eslint-disable-next-line complexity DOMPurify.sanitize = function (dirty) { let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; let body = null; let importedNode = null; let currentNode = null; let returnNode = null; /* Make sure we have a string to sanitize. DO NOT return early, as this will return the wrong type if the user has requested a DOM object rather than a string */ IS_EMPTY_INPUT = !dirty; if (IS_EMPTY_INPUT) { dirty = ''; } /* Stringify, in case dirty is an object */ if (typeof dirty !== 'string' && !_isNode(dirty)) { if (typeof dirty.toString === 'function') { dirty = dirty.toString(); if (typeof dirty !== 'string') { throw typeErrorCreate('dirty is not a string, aborting'); } } else { throw typeErrorCreate('toString is not a function'); } } /* Return dirty HTML if DOMPurify cannot run */ if (!DOMPurify.isSupported) { return dirty; } /* Assign config vars */ if (!SET_CONFIG) { _parseConfig(cfg); } /* Clean up removed elements */ DOMPurify.removed = []; /* Check if dirty is correctly typed for IN_PLACE */ if (typeof dirty === 'string') { IN_PLACE = false; } if (IN_PLACE) { /* Do some early pre-sanitization to avoid unsafe root nodes */ if (dirty.nodeName) { const tagName = transformCaseFunc(dirty.nodeName); if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place'); } } } else if (dirty instanceof Node) { /* If dirty is a DOM element, append to an empty document to avoid elements being stripped by the parser */ body = _initDocument(''); importedNode = body.ownerDocument.importNode(dirty, true); if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') { /* Node is already a body, use as is */ body = importedNode; } else if (importedNode.nodeName === 'HTML') { body = importedNode; } else { // eslint-disable-next-line unicorn/prefer-dom-node-append body.appendChild(importedNode); } } else { /* Exit directly if we have nothing to do */ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes dirty.indexOf('<') === -1) { return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; } /* Initialize the document to work on */ body = _initDocument(dirty); /* Check we have a DOM node from the data */ if (!body) { return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; } } /* Remove first element node (ours) if FORCE_BODY is set */ if (body && FORCE_BODY) { _forceRemove(body.firstChild); } /* Get node iterator */ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body); /* Now start iterating over the created document */ while (currentNode = nodeIterator.nextNode()) { /* Sanitize tags and elements */ _sanitizeElements(currentNode); /* Check attributes next */ _sanitizeAttributes(currentNode); /* Shadow DOM detected, sanitize it */ if (currentNode.content instanceof DocumentFragment) { _sanitizeShadowDOM2(currentNode.content); } } /* If we sanitized `dirty` in-place, return it. */ if (IN_PLACE) { return dirty; } /* Return sanitized string or DOM */ if (RETURN_DOM) { if (RETURN_DOM_FRAGMENT) { returnNode = createDocumentFragment.call(body.ownerDocument); while (body.firstChild) { // eslint-disable-next-line unicorn/prefer-dom-node-append returnNode.appendChild(body.firstChild); } } else { returnNode = body; } if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) { /* AdoptNode() is not used because internal state is not reset (e.g. the past names map of a HTMLFormElement), this is safe in theory but we would rather not risk another attack vector. The state that is cloned by importNode() is explicitly defined by the specs. */ returnNode = importNode.call(originalDocument, returnNode, true); } return returnNode; } let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; /* Serialize doctype if allowed */ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { serializedHTML = '\n' + serializedHTML; } /* Sanitize final string template-safe */ if (SAFE_FOR_TEMPLATES) { arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { serializedHTML = stringReplace(serializedHTML, expr, ' '); }); } return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; }; DOMPurify.setConfig = function () { let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _parseConfig(cfg); SET_CONFIG = true; }; DOMPurify.clearConfig = function () { CONFIG = null; SET_CONFIG = false; }; DOMPurify.isValidAttribute = function (tag, attr, value) { /* Initialize shared config vars if necessary. */ if (!CONFIG) { _parseConfig({}); } const lcTag = transformCaseFunc(tag); const lcName = transformCaseFunc(attr); return _isValidAttribute(lcTag, lcName, value); }; DOMPurify.addHook = function (entryPoint, hookFunction) { if (typeof hookFunction !== 'function') { return; } arrayPush(hooks[entryPoint], hookFunction); }; DOMPurify.removeHook = function (entryPoint, hookFunction) { if (hookFunction !== undefined) { const index = arrayLastIndexOf(hooks[entryPoint], hookFunction); return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0]; } return arrayPop(hooks[entryPoint]); }; DOMPurify.removeHooks = function (entryPoint) { hooks[entryPoint] = []; }; DOMPurify.removeAllHooks = function () { hooks = _createHooksMap(); }; return DOMPurify; } var purify = createDOMPurify(); export { purify as default }; //# sourceMappingURL=purify.es.mjs.map ================================================ FILE: dist/purify.js ================================================ /*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.DOMPurify = factory()); })(this, (function () { 'use strict'; const { entries, setPrototypeOf, isFrozen, getPrototypeOf, getOwnPropertyDescriptor } = Object; let { freeze, seal, create } = Object; // eslint-disable-line import/no-mutable-exports let { apply, construct } = typeof Reflect !== 'undefined' && Reflect; if (!freeze) { freeze = function freeze(x) { return x; }; } if (!seal) { seal = function seal(x) { return x; }; } if (!apply) { apply = function apply(func, thisArg) { for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } return func.apply(thisArg, args); }; } if (!construct) { construct = function construct(Func) { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } return new Func(...args); }; } const arrayForEach = unapply(Array.prototype.forEach); const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf); const arrayPop = unapply(Array.prototype.pop); const arrayPush = unapply(Array.prototype.push); const arraySplice = unapply(Array.prototype.splice); const stringToLowerCase = unapply(String.prototype.toLowerCase); const stringToString = unapply(String.prototype.toString); const stringMatch = unapply(String.prototype.match); const stringReplace = unapply(String.prototype.replace); const stringIndexOf = unapply(String.prototype.indexOf); const stringTrim = unapply(String.prototype.trim); const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty); const regExpTest = unapply(RegExp.prototype.test); const typeErrorCreate = unconstruct(TypeError); /** * Creates a new function that calls the given function with a specified thisArg and arguments. * * @param func - The function to be wrapped and called. * @returns A new function that calls the given function with a specified thisArg and arguments. */ function unapply(func) { return function (thisArg) { if (thisArg instanceof RegExp) { thisArg.lastIndex = 0; } for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { args[_key3 - 1] = arguments[_key3]; } return apply(func, thisArg, args); }; } /** * Creates a new function that constructs an instance of the given constructor function with the provided arguments. * * @param func - The constructor function to be wrapped and called. * @returns A new function that constructs an instance of the given constructor function with the provided arguments. */ function unconstruct(Func) { return function () { for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { args[_key4] = arguments[_key4]; } return construct(Func, args); }; } /** * Add properties to a lookup table * * @param set - The set to which elements will be added. * @param array - The array containing elements to be added to the set. * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set. * @returns The modified set with added elements. */ function addToSet(set, array) { let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase; if (setPrototypeOf) { // Make 'in' and truthy checks like Boolean(set.constructor) // independent of any properties defined on Object.prototype. // Prevent prototype setters from intercepting set as a this value. setPrototypeOf(set, null); } let l = array.length; while (l--) { let element = array[l]; if (typeof element === 'string') { const lcElement = transformCaseFunc(element); if (lcElement !== element) { // Config presets (e.g. tags.js, attrs.js) are immutable. if (!isFrozen(array)) { array[l] = lcElement; } element = lcElement; } } set[element] = true; } return set; } /** * Clean up an array to harden against CSPP * * @param array - The array to be cleaned. * @returns The cleaned version of the array */ function cleanArray(array) { for (let index = 0; index < array.length; index++) { const isPropertyExist = objectHasOwnProperty(array, index); if (!isPropertyExist) { array[index] = null; } } return array; } /** * Shallow clone an object * * @param object - The object to be cloned. * @returns A new object that copies the original. */ function clone(object) { const newObject = create(null); for (const [property, value] of entries(object)) { const isPropertyExist = objectHasOwnProperty(object, property); if (isPropertyExist) { if (Array.isArray(value)) { newObject[property] = cleanArray(value); } else if (value && typeof value === 'object' && value.constructor === Object) { newObject[property] = clone(value); } else { newObject[property] = value; } } } return newObject; } /** * This method automatically checks if the prop is function or getter and behaves accordingly. * * @param object - The object to look up the getter function in its prototype chain. * @param prop - The property name for which to find the getter function. * @returns The getter function found in the prototype chain or a fallback function. */ function lookupGetter(object, prop) { while (object !== null) { const desc = getOwnPropertyDescriptor(object, prop); if (desc) { if (desc.get) { return unapply(desc.get); } if (typeof desc.value === 'function') { return unapply(desc.value); } } object = getPrototypeOf(object); } function fallbackValue() { return null; } return fallbackValue; } const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); // List of SVG elements that are disallowed by default. // We still need to know them so that we can do namespace // checks properly in case one wants to add them to // allow-list. const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); // Similarly to SVG, we want to know all MathML elements, // even those that we disallow by default. const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); const text = freeze(['#text']); const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']); const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); // eslint-disable-next-line unicorn/better-regex const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape ); const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex ); const DOCTYPE_NAME = seal(/^html$/i); const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i); var EXPRESSIONS = /*#__PURE__*/Object.freeze({ __proto__: null, ARIA_ATTR: ARIA_ATTR, ATTR_WHITESPACE: ATTR_WHITESPACE, CUSTOM_ELEMENT: CUSTOM_ELEMENT, DATA_ATTR: DATA_ATTR, DOCTYPE_NAME: DOCTYPE_NAME, ERB_EXPR: ERB_EXPR, IS_ALLOWED_URI: IS_ALLOWED_URI, IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA, MUSTACHE_EXPR: MUSTACHE_EXPR, TMPLIT_EXPR: TMPLIT_EXPR }); /* eslint-disable @typescript-eslint/indent */ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType const NODE_TYPE = { element: 1, attribute: 2, text: 3, cdataSection: 4, entityReference: 5, // Deprecated entityNode: 6, // Deprecated progressingInstruction: 7, comment: 8, document: 9, documentType: 10, documentFragment: 11, notation: 12 // Deprecated }; const getGlobal = function getGlobal() { return typeof window === 'undefined' ? null : window; }; /** * Creates a no-op policy for internal use only. * Don't export this function outside this module! * @param trustedTypes The policy factory. * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix). * @return The policy created (or null, if Trusted Types * are not supported or creating the policy failed). */ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) { if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') { return null; } // Allow the callers to control the unique policy name // by adding a data-tt-policy-suffix to the script element with the DOMPurify. // Policy creation with duplicate names throws in Trusted Types. let suffix = null; const ATTR_NAME = 'data-tt-policy-suffix'; if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) { suffix = purifyHostElement.getAttribute(ATTR_NAME); } const policyName = 'dompurify' + (suffix ? '#' + suffix : ''); try { return trustedTypes.createPolicy(policyName, { createHTML(html) { return html; }, createScriptURL(scriptUrl) { return scriptUrl; } }); } catch (_) { // Policy creation failed (most likely another DOMPurify script has // already run). Skip creating the policy, as this will only cause errors // if TT are enforced. console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); return null; } }; const _createHooksMap = function _createHooksMap() { return { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] }; }; function createDOMPurify() { let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); const DOMPurify = root => createDOMPurify(root); DOMPurify.version = '3.3.3'; DOMPurify.removed = []; if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) { // Not running in a browser, provide a factory function // so that you can pass your own Window DOMPurify.isSupported = false; return DOMPurify; } let { document } = window; const originalDocument = document; const currentScript = originalDocument.currentScript; const { DocumentFragment, HTMLTemplateElement, Node, Element, NodeFilter, NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap, HTMLFormElement, DOMParser, trustedTypes } = window; const ElementPrototype = Element.prototype; const cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); const remove = lookupGetter(ElementPrototype, 'remove'); const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); const getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a // new document created via createHTMLDocument. As per the spec // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) // a new empty registry is used when creating a template contents owner // document, so we use that as our parent document to ensure nothing // is inherited. if (typeof HTMLTemplateElement === 'function') { const template = document.createElement('template'); if (template.content && template.content.ownerDocument) { document = template.content.ownerDocument; } } let trustedTypesPolicy; let emptyHTML = ''; const { implementation, createNodeIterator, createDocumentFragment, getElementsByTagName } = document; const { importNode } = originalDocument; let hooks = _createHooksMap(); /** * Expose whether this browser supports running the full DOMPurify. */ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined; const { MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR, DATA_ATTR, ARIA_ATTR, IS_SCRIPT_OR_DATA, ATTR_WHITESPACE, CUSTOM_ELEMENT } = EXPRESSIONS; let { IS_ALLOWED_URI: IS_ALLOWED_URI$1 } = EXPRESSIONS; /** * We consider the elements and attributes below to be safe. Ideally * don't add any new ones but feel free to remove unwanted ones. */ /* allowed element names */ let ALLOWED_TAGS = null; const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]); /* Allowed attribute names */ let ALLOWED_ATTR = null; const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]); /* * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements. * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements) * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list) * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`. */ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, { tagNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, attributeNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, allowCustomizedBuiltInElements: { writable: true, configurable: false, enumerable: true, value: false } })); /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ let FORBID_TAGS = null; /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ let FORBID_ATTR = null; /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, { tagCheck: { writable: true, configurable: false, enumerable: true, value: null }, attributeCheck: { writable: true, configurable: false, enumerable: true, value: null } })); /* Decide if ARIA attributes are okay */ let ALLOW_ARIA_ATTR = true; /* Decide if custom data attributes are okay */ let ALLOW_DATA_ATTR = true; /* Decide if unknown protocols are okay */ let ALLOW_UNKNOWN_PROTOCOLS = false; /* Decide if self-closing tags in attributes are allowed. * Usually removed due to a mXSS issue in jQuery 3.0 */ let ALLOW_SELF_CLOSE_IN_ATTR = true; /* Output should be safe for common template engines. * This means, DOMPurify removes data attributes, mustaches and ERB */ let SAFE_FOR_TEMPLATES = false; /* Output should be safe even for XML used within HTML and alike. * This means, DOMPurify removes comments when containing risky content. */ let SAFE_FOR_XML = true; /* Decide if document with ... should be returned */ let WHOLE_DOCUMENT = false; /* Track whether config is already set on this instance of DOMPurify. */ let SET_CONFIG = false; /* Decide if all elements (e.g. style, script) must be children of * document.body. By default, browsers might move them to document.head */ let FORCE_BODY = false; /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html * string (or a TrustedHTML object if Trusted Types are supported). * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead */ let RETURN_DOM = false; /* Decide if a DOM `DocumentFragment` should be returned, instead of a html * string (or a TrustedHTML object if Trusted Types are supported) */ let RETURN_DOM_FRAGMENT = false; /* Try to return a Trusted Type object instead of a string, return a string in * case Trusted Types are not supported */ let RETURN_TRUSTED_TYPE = false; /* Output should be free from DOM clobbering attacks? * This sanitizes markups named with colliding, clobberable built-in DOM APIs. */ let SANITIZE_DOM = true; /* Achieve full DOM Clobbering protection by isolating the namespace of named * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules. * * HTML/DOM spec rules that enable DOM Clobbering: * - Named Access on Window (§7.3.3) * - DOM Tree Accessors (§3.1.5) * - Form Element Parent-Child Relations (§4.10.3) * - Iframe srcdoc / Nested WindowProxies (§4.8.5) * - HTMLCollection (§4.2.10.2) * * Namespace isolation is implemented by prefixing `id` and `name` attributes * with a constant string, i.e., `user-content-` */ let SANITIZE_NAMED_PROPS = false; const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-'; /* Keep element content when removing element? */ let KEEP_CONTENT = true; /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead * of importing it into a new Document and returning a sanitized copy */ let IN_PLACE = false; /* Allow usage of profiles like html, svg and mathMl */ let USE_PROFILES = {}; /* Tags to ignore content of when KEEP_CONTENT is true */ let FORBID_CONTENTS = null; const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); /* Tags that are safe for data: URIs */ let DATA_URI_TAGS = null; const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); /* Attributes safe for values like "javascript:" */ let URI_SAFE_ATTRIBUTES = null; const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; /* Document namespace */ let NAMESPACE = HTML_NAMESPACE; let IS_EMPTY_INPUT = false; /* Allowed XHTML+XML namespaces */ let ALLOWED_NAMESPACES = null; const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString); let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']); // Certain elements are allowed in both SVG and HTML // namespace. We need to specify them explicitly // so that they don't get erroneously deleted from // HTML namespace. const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']); /* Parsing of strict XHTML documents */ let PARSER_MEDIA_TYPE = null; const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; const DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; let transformCaseFunc = null; /* Keep a reference to config to pass to hooks */ let CONFIG = null; /* Ideally, do not touch anything below this line */ /* ______________________________________________ */ const formElement = document.createElement('form'); const isRegexOrFunction = function isRegexOrFunction(testValue) { return testValue instanceof RegExp || testValue instanceof Function; }; /** * _parseConfig * * @param cfg optional config literal */ // eslint-disable-next-line complexity const _parseConfig = function _parseConfig() { let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; if (CONFIG && CONFIG === cfg) { return; } /* Shield configuration object from tampering */ if (!cfg || typeof cfg !== 'object') { cfg = {}; } /* Shield configuration object from prototype pollution */ cfg = clone(cfg); PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase; /* Set configuration parameters */ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS; ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR; ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES; URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES; DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS; FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS; FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({}); FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({}); USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false; ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false RETURN_DOM = cfg.RETURN_DOM || false; // Default false RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false FORCE_BODY = cfg.FORCE_BODY || false; // Default false SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true IN_PLACE = cfg.IN_PLACE || false; // Default false IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI; NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS; HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS; CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {}; if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; } if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) { CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck; } if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') { CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements; } if (SAFE_FOR_TEMPLATES) { ALLOW_DATA_ATTR = false; } if (RETURN_DOM_FRAGMENT) { RETURN_DOM = true; } /* Parse profile info */ if (USE_PROFILES) { ALLOWED_TAGS = addToSet({}, text); ALLOWED_ATTR = create(null); if (USE_PROFILES.html === true) { addToSet(ALLOWED_TAGS, html$1); addToSet(ALLOWED_ATTR, html); } if (USE_PROFILES.svg === true) { addToSet(ALLOWED_TAGS, svg$1); addToSet(ALLOWED_ATTR, svg); addToSet(ALLOWED_ATTR, xml); } if (USE_PROFILES.svgFilters === true) { addToSet(ALLOWED_TAGS, svgFilters); addToSet(ALLOWED_ATTR, svg); addToSet(ALLOWED_ATTR, xml); } if (USE_PROFILES.mathMl === true) { addToSet(ALLOWED_TAGS, mathMl$1); addToSet(ALLOWED_ATTR, mathMl); addToSet(ALLOWED_ATTR, xml); } } /* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */ if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) { EXTRA_ELEMENT_HANDLING.tagCheck = null; } if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) { EXTRA_ELEMENT_HANDLING.attributeCheck = null; } /* Merge configuration parameters */ if (cfg.ADD_TAGS) { if (typeof cfg.ADD_TAGS === 'function') { EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS; } else { if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { ALLOWED_TAGS = clone(ALLOWED_TAGS); } addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc); } } if (cfg.ADD_ATTR) { if (typeof cfg.ADD_ATTR === 'function') { EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR; } else { if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { ALLOWED_ATTR = clone(ALLOWED_ATTR); } addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc); } } if (cfg.ADD_URI_SAFE_ATTR) { addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc); } if (cfg.FORBID_CONTENTS) { if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { FORBID_CONTENTS = clone(FORBID_CONTENTS); } addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc); } if (cfg.ADD_FORBID_CONTENTS) { if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { FORBID_CONTENTS = clone(FORBID_CONTENTS); } addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc); } /* Add #text in case KEEP_CONTENT is set to true */ if (KEEP_CONTENT) { ALLOWED_TAGS['#text'] = true; } /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ if (WHOLE_DOCUMENT) { addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); } /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ if (ALLOWED_TAGS.table) { addToSet(ALLOWED_TAGS, ['tbody']); delete FORBID_TAGS.tbody; } if (cfg.TRUSTED_TYPES_POLICY) { if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') { throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); } if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') { throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); } // Overwrite existing TrustedTypes policy. trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; // Sign local variables required by `sanitize`. emptyHTML = trustedTypesPolicy.createHTML(''); } else { // Uninitialized policy, attempt to initialize the internal dompurify policy. if (trustedTypesPolicy === undefined) { trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript); } // If creating the internal policy succeeded sign internal variables. if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') { emptyHTML = trustedTypesPolicy.createHTML(''); } } // Prevent further manipulation of configuration. // Not available in IE8, Safari 5, etc. if (freeze) { freeze(cfg); } CONFIG = cfg; }; /* Keep track of all possible SVG and MathML tags * so that we can perform the namespace checks * correctly. */ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]); const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]); /** * @param element a DOM element whose namespace is being checked * @returns Return false if the element has a * namespace that a spec-compliant parser would never * return. Return true otherwise. */ const _checkValidNamespace = function _checkValidNamespace(element) { let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode // can be null. We just simulate parent in this case. if (!parent || !parent.tagName) { parent = { namespaceURI: NAMESPACE, tagName: 'template' }; } const tagName = stringToLowerCase(element.tagName); const parentTagName = stringToLowerCase(parent.tagName); if (!ALLOWED_NAMESPACES[element.namespaceURI]) { return false; } if (element.namespaceURI === SVG_NAMESPACE) { // The only way to switch from HTML namespace to SVG // is via . If it happens via any other tag, then // it should be killed. if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === 'svg'; } // The only way to switch from MathML to SVG is via` // svg if parent is either or MathML // text integration points. if (parent.namespaceURI === MATHML_NAMESPACE) { return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); } // We only allow elements that are defined in SVG // spec. All others are disallowed in SVG namespace. return Boolean(ALL_SVG_TAGS[tagName]); } if (element.namespaceURI === MATHML_NAMESPACE) { // The only way to switch from HTML namespace to MathML // is via . If it happens via any other tag, then // it should be killed. if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === 'math'; } // The only way to switch from SVG to MathML is via // and HTML integration points if (parent.namespaceURI === SVG_NAMESPACE) { return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; } // We only allow elements that are defined in MathML // spec. All others are disallowed in MathML namespace. return Boolean(ALL_MATHML_TAGS[tagName]); } if (element.namespaceURI === HTML_NAMESPACE) { // The only way to switch from SVG to HTML is via // HTML integration points, and from MathML to HTML // is via MathML text integration points if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { return false; } if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { return false; } // We disallow tags that are specific for MathML // or SVG and should never appear in HTML namespace return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); } // For XHTML and XML documents that support custom namespaces if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) { return true; } // The code should never reach this place (this means // that the element somehow got namespace that is not // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES). // Return false just in case. return false; }; /** * _forceRemove * * @param node a DOM node */ const _forceRemove = function _forceRemove(node) { arrayPush(DOMPurify.removed, { element: node }); try { // eslint-disable-next-line unicorn/prefer-dom-node-remove getParentNode(node).removeChild(node); } catch (_) { remove(node); } }; /** * _removeAttribute * * @param name an Attribute name * @param element a DOM node */ const _removeAttribute = function _removeAttribute(name, element) { try { arrayPush(DOMPurify.removed, { attribute: element.getAttributeNode(name), from: element }); } catch (_) { arrayPush(DOMPurify.removed, { attribute: null, from: element }); } element.removeAttribute(name); // We void attribute values for unremovable "is" attributes if (name === 'is') { if (RETURN_DOM || RETURN_DOM_FRAGMENT) { try { _forceRemove(element); } catch (_) {} } else { try { element.setAttribute(name, ''); } catch (_) {} } } }; /** * _initDocument * * @param dirty - a string of dirty markup * @return a DOM, filled with the dirty markup */ const _initDocument = function _initDocument(dirty) { /* Create a HTML document */ let doc = null; let leadingWhitespace = null; if (FORCE_BODY) { dirty = '' + dirty; } else { /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ const matches = stringMatch(dirty, /^[\r\n\t ]+/); leadingWhitespace = matches && matches[0]; } if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) { // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict) dirty = '' + dirty + ''; } const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; /* * Use the DOMParser API by default, fallback later if needs be * DOMParser not work for svg when has multiple root element. */ if (NAMESPACE === HTML_NAMESPACE) { try { doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); } catch (_) {} } /* Use createHTMLDocument in case DOMParser is not available */ if (!doc || !doc.documentElement) { doc = implementation.createDocument(NAMESPACE, 'template', null); try { doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload; } catch (_) { // Syntax error if dirtyPayload is invalid xml } } const body = doc.body || doc.documentElement; if (dirty && leadingWhitespace) { body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null); } /* Work on whole document or just its body */ if (NAMESPACE === HTML_NAMESPACE) { return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; } return WHOLE_DOCUMENT ? doc.documentElement : body; }; /** * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. * * @param root The root element or node to start traversing on. * @return The created NodeIterator */ const _createNodeIterator = function _createNodeIterator(root) { return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null); }; /** * _isClobbered * * @param element element to check for clobbering attacks * @return true if clobbered, false if safe */ const _isClobbered = function _isClobbered(element) { return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function'); }; /** * Checks whether the given object is a DOM node. * * @param value object to check whether it's a DOM node * @return true is object is a DOM node */ const _isNode = function _isNode(value) { return typeof Node === 'function' && value instanceof Node; }; function _executeHooks(hooks, currentNode, data) { arrayForEach(hooks, hook => { hook.call(DOMPurify, currentNode, data, CONFIG); }); } /** * _sanitizeElements * * @protect nodeName * @protect textContent * @protect removeChild * @param currentNode to check for permission to exist * @return true if node was killed, false if left alive */ const _sanitizeElements = function _sanitizeElements(currentNode) { let content = null; /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeElements, currentNode, null); /* Check if element is clobbered or can clobber */ if (_isClobbered(currentNode)) { _forceRemove(currentNode); return true; } /* Now let's check the element's type and name */ const tagName = transformCaseFunc(currentNode.nodeName); /* Execute a hook if present */ _executeHooks(hooks.uponSanitizeElement, currentNode, { tagName, allowedTags: ALLOWED_TAGS }); /* Detect mXSS attempts abusing namespace confusion */ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) { _forceRemove(currentNode); return true; } /* Remove any occurrence of processing instructions */ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) { _forceRemove(currentNode); return true; } /* Remove any kind of possibly harmful comments */ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) { _forceRemove(currentNode); return true; } /* Remove element if anything forbids its presence */ if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) { /* Check if we have a custom element to handle */ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) { if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) { return false; } if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) { return false; } } /* Keep content except for bad-listed elements */ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { const parentNode = getParentNode(currentNode) || currentNode.parentNode; const childNodes = getChildNodes(currentNode) || currentNode.childNodes; if (childNodes && parentNode) { const childCount = childNodes.length; for (let i = childCount - 1; i >= 0; --i) { const childClone = cloneNode(childNodes[i], true); childClone.__removalCount = (currentNode.__removalCount || 0) + 1; parentNode.insertBefore(childClone, getNextSibling(currentNode)); } } } _forceRemove(currentNode); return true; } /* Check whether element has a valid namespace */ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { _forceRemove(currentNode); return true; } /* Make sure that older browsers don't get fallback-tag mXSS */ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) { _forceRemove(currentNode); return true; } /* Sanitize element content to be template-safe */ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) { /* Get the element's text content */ content = currentNode.textContent; arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { content = stringReplace(content, expr, ' '); }); if (currentNode.textContent !== content) { arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); currentNode.textContent = content; } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeElements, currentNode, null); return false; }; /** * _isValidAttribute * * @param lcTag Lowercase tag name of containing element. * @param lcName Lowercase attribute name. * @param value Attribute value. * @return Returns true if `value` is valid, otherwise false. */ // eslint-disable-next-line complexity const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */ if (FORBID_ATTR[lcName]) { return false; } /* Make sure attribute cannot clobber */ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { return false; } /* Allow valid data-* attributes: At least one character after "-" (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) We don't need to check the value; it's always URI safe. */ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || // Alternative, second condition checks if it's an `is`-attribute, AND // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else { return false; } /* Check value is safe. First, is attr inert? If so, is safe */ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) { return false; } else ; return true; }; /** * _isBasicCustomElement * checks if at least one dash is included in tagName, and it's not the first char * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name * * @param tagName name of the tag of the node to sanitize * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false. */ const _isBasicCustomElement = function _isBasicCustomElement(tagName) { return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT); }; /** * _sanitizeAttributes * * @protect attributes * @protect nodeName * @protect removeAttribute * @protect setAttribute * * @param currentNode to sanitize */ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) { /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null); const { attributes } = currentNode; /* Check if we have attributes; if not we might have a text node */ if (!attributes || _isClobbered(currentNode)) { return; } const hookEvent = { attrName: '', attrValue: '', keepAttr: true, allowedAttributes: ALLOWED_ATTR, forceKeepAttr: undefined }; let l = attributes.length; /* Go backwards over all attributes; safely remove bad ones */ while (l--) { const attr = attributes[l]; const { name, namespaceURI, value: attrValue } = attr; const lcName = transformCaseFunc(name); const initValue = attrValue; let value = name === 'value' ? initValue : stringTrim(initValue); /* Execute a hook if present */ hookEvent.attrName = lcName; hookEvent.attrValue = value; hookEvent.keepAttr = true; hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent); value = hookEvent.attrValue; /* Full DOM Clobbering protection via namespace isolation, * Prefix id and name attributes with `user-content-` */ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) { // Remove the attribute with this value _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value value = SANITIZE_NAMED_PROPS_PREFIX + value; } /* Work around a security issue with comments inside attributes */ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) { _removeAttribute(name, currentNode); continue; } /* Make sure we cannot easily use animated hrefs, even if animations are allowed */ if (lcName === 'attributename' && stringMatch(value, 'href')) { _removeAttribute(name, currentNode); continue; } /* Did the hooks approve of the attribute? */ if (hookEvent.forceKeepAttr) { continue; } /* Did the hooks approve of the attribute? */ if (!hookEvent.keepAttr) { _removeAttribute(name, currentNode); continue; } /* Work around a security issue in jQuery 3.0 */ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) { _removeAttribute(name, currentNode); continue; } /* Sanitize attribute content to be template-safe */ if (SAFE_FOR_TEMPLATES) { arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { value = stringReplace(value, expr, ' '); }); } /* Is `value` valid for this attribute? */ const lcTag = transformCaseFunc(currentNode.nodeName); if (!_isValidAttribute(lcTag, lcName, value)) { _removeAttribute(name, currentNode); continue; } /* Handle attributes that require Trusted Types */ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') { if (namespaceURI) ; else { switch (trustedTypes.getAttributeType(lcTag, lcName)) { case 'TrustedHTML': { value = trustedTypesPolicy.createHTML(value); break; } case 'TrustedScriptURL': { value = trustedTypesPolicy.createScriptURL(value); break; } } } } /* Handle invalid data-* attribute set by try-catching it */ if (value !== initValue) { try { if (namespaceURI) { currentNode.setAttributeNS(namespaceURI, name, value); } else { /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ currentNode.setAttribute(name, value); } if (_isClobbered(currentNode)) { _forceRemove(currentNode); } else { arrayPop(DOMPurify.removed); } } catch (_) { _removeAttribute(name, currentNode); } } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null); }; /** * _sanitizeShadowDOM * * @param fragment to iterate over recursively */ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) { let shadowNode = null; const shadowIterator = _createNodeIterator(fragment); /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null); while (shadowNode = shadowIterator.nextNode()) { /* Execute a hook if present */ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null); /* Sanitize tags and elements */ _sanitizeElements(shadowNode); /* Check attributes next */ _sanitizeAttributes(shadowNode); /* Deep shadow DOM detected */ if (shadowNode.content instanceof DocumentFragment) { _sanitizeShadowDOM2(shadowNode.content); } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null); }; // eslint-disable-next-line complexity DOMPurify.sanitize = function (dirty) { let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; let body = null; let importedNode = null; let currentNode = null; let returnNode = null; /* Make sure we have a string to sanitize. DO NOT return early, as this will return the wrong type if the user has requested a DOM object rather than a string */ IS_EMPTY_INPUT = !dirty; if (IS_EMPTY_INPUT) { dirty = ''; } /* Stringify, in case dirty is an object */ if (typeof dirty !== 'string' && !_isNode(dirty)) { if (typeof dirty.toString === 'function') { dirty = dirty.toString(); if (typeof dirty !== 'string') { throw typeErrorCreate('dirty is not a string, aborting'); } } else { throw typeErrorCreate('toString is not a function'); } } /* Return dirty HTML if DOMPurify cannot run */ if (!DOMPurify.isSupported) { return dirty; } /* Assign config vars */ if (!SET_CONFIG) { _parseConfig(cfg); } /* Clean up removed elements */ DOMPurify.removed = []; /* Check if dirty is correctly typed for IN_PLACE */ if (typeof dirty === 'string') { IN_PLACE = false; } if (IN_PLACE) { /* Do some early pre-sanitization to avoid unsafe root nodes */ if (dirty.nodeName) { const tagName = transformCaseFunc(dirty.nodeName); if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place'); } } } else if (dirty instanceof Node) { /* If dirty is a DOM element, append to an empty document to avoid elements being stripped by the parser */ body = _initDocument(''); importedNode = body.ownerDocument.importNode(dirty, true); if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') { /* Node is already a body, use as is */ body = importedNode; } else if (importedNode.nodeName === 'HTML') { body = importedNode; } else { // eslint-disable-next-line unicorn/prefer-dom-node-append body.appendChild(importedNode); } } else { /* Exit directly if we have nothing to do */ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes dirty.indexOf('<') === -1) { return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; } /* Initialize the document to work on */ body = _initDocument(dirty); /* Check we have a DOM node from the data */ if (!body) { return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; } } /* Remove first element node (ours) if FORCE_BODY is set */ if (body && FORCE_BODY) { _forceRemove(body.firstChild); } /* Get node iterator */ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body); /* Now start iterating over the created document */ while (currentNode = nodeIterator.nextNode()) { /* Sanitize tags and elements */ _sanitizeElements(currentNode); /* Check attributes next */ _sanitizeAttributes(currentNode); /* Shadow DOM detected, sanitize it */ if (currentNode.content instanceof DocumentFragment) { _sanitizeShadowDOM2(currentNode.content); } } /* If we sanitized `dirty` in-place, return it. */ if (IN_PLACE) { return dirty; } /* Return sanitized string or DOM */ if (RETURN_DOM) { if (RETURN_DOM_FRAGMENT) { returnNode = createDocumentFragment.call(body.ownerDocument); while (body.firstChild) { // eslint-disable-next-line unicorn/prefer-dom-node-append returnNode.appendChild(body.firstChild); } } else { returnNode = body; } if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) { /* AdoptNode() is not used because internal state is not reset (e.g. the past names map of a HTMLFormElement), this is safe in theory but we would rather not risk another attack vector. The state that is cloned by importNode() is explicitly defined by the specs. */ returnNode = importNode.call(originalDocument, returnNode, true); } return returnNode; } let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; /* Serialize doctype if allowed */ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { serializedHTML = '\n' + serializedHTML; } /* Sanitize final string template-safe */ if (SAFE_FOR_TEMPLATES) { arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { serializedHTML = stringReplace(serializedHTML, expr, ' '); }); } return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; }; DOMPurify.setConfig = function () { let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _parseConfig(cfg); SET_CONFIG = true; }; DOMPurify.clearConfig = function () { CONFIG = null; SET_CONFIG = false; }; DOMPurify.isValidAttribute = function (tag, attr, value) { /* Initialize shared config vars if necessary. */ if (!CONFIG) { _parseConfig({}); } const lcTag = transformCaseFunc(tag); const lcName = transformCaseFunc(attr); return _isValidAttribute(lcTag, lcName, value); }; DOMPurify.addHook = function (entryPoint, hookFunction) { if (typeof hookFunction !== 'function') { return; } arrayPush(hooks[entryPoint], hookFunction); }; DOMPurify.removeHook = function (entryPoint, hookFunction) { if (hookFunction !== undefined) { const index = arrayLastIndexOf(hooks[entryPoint], hookFunction); return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0]; } return arrayPop(hooks[entryPoint]); }; DOMPurify.removeHooks = function (entryPoint) { hooks[entryPoint] = []; }; DOMPurify.removeAllHooks = function () { hooks = _createHooksMap(); }; return DOMPurify; } var purify = createDOMPurify(); return purify; })); //# sourceMappingURL=purify.js.map ================================================ FILE: package.json ================================================ { "scripts": { "lint": "xo src/*.ts", "format": "npm run format:js && npm run format:md", "format:md": "prettier --write --parser markdown '**/*.md'", "format:js": "prettier --write '{src,demos,scripts,test,website}/*.{js,ts}'", "commit-amend-build": "scripts/commit-amend-build.sh", "prebuild": "rimraf dist/**", "dev": "cross-env NODE_ENV=development BABEL_ENV=rollup rollup -w -c -o dist/purify.js", "build": "npm run build:types && npm run build:rollup && npm run build:fix-types && npm run build:cleanup", "build:types": "tsc --outDir dist/types --declaration --emitDeclarationOnly", "build:rollup": "rollup -c", "build:fix-types": "node ./scripts/fix-types.js", "build:umd": "rollup -c -f umd -o dist/purify.js", "build:umd:min": "rollup -c -f umd -o dist/purify.min.js -p terser", "build:es": "rollup -c -f es -o dist/purify.es.mjs", "build:cjs": "rollup -c -f cjs -o dist/purify.cjs.js", "build:cleanup": "rimraf dist/types", "test:jsdom": "cross-env NODE_ENV=test BABEL_ENV=rollup node test/jsdom-node-runner --dot", "test:karma": "cross-env NODE_ENV=test BABEL_ENV=rollup karma start test/karma.conf.js --log-level warn ", "test:ci": "cross-env NODE_ENV=test BABEL_ENV=rollup npm run test:jsdom && npm run test:karma -- --log-level error --reporters dots --single-run --shouldTestOnBrowserStack=\"${TEST_BROWSERSTACK}\" --shouldProbeOnly=\"${TEST_PROBE_ONLY}\"", "test": "cross-env NODE_ENV=test BABEL_ENV=rollup npm run lint && npm run test:jsdom && npm run test:karma -- --browsers Chrome", "verify-typescript": "node ./typescript/verify.js" }, "main": "./dist/purify.cjs.js", "module": "./dist/purify.es.mjs", "browser": "./dist/purify.js", "production": "./dist/purify.min.js", "types": "./dist/purify.cjs.d.ts", "exports": { ".": { "import": { "types": "./dist/purify.es.d.mts", "default": "./dist/purify.es.mjs" }, "default": { "types": "./dist/purify.cjs.d.ts", "default": "./dist/purify.cjs.js" } }, "./purify.min.js": "./dist/purify.min.js", "./purify.js": "./dist/purify.js", "./dist/purify.min.js": "./dist/purify.min.js", "./dist/purify.js": "./dist/purify.js" }, "files": [ "dist" ], "pre-commit": [ "lint", "build", "commit-amend-build" ], "xo": { "semicolon": true, "space": 2, "extends": [ "prettier" ], "plugins": [ "prettier" ], "rules": { "import/no-useless-path-segments": 0, "unicorn/prefer-optional-catch-binding": 0, "unicorn/prefer-node-remove": 0, "prettier/prettier": [ "error", { "trailingComma": "es5", "singleQuote": true } ], "camelcase": [ "error", { "properties": "never" } ], "@typescript-eslint/ban-types": 0, "@typescript-eslint/consistent-type-definitions": 0, "@typescript-eslint/indent": 0, "@typescript-eslint/naming-convention": 0, "@typescript-eslint/no-throw-literal": 0, "@typescript-eslint/no-unnecessary-boolean-literal-compare": 0, "@typescript-eslint/no-unsafe-argument": 0, "@typescript-eslint/no-unsafe-assignment": 0, "@typescript-eslint/no-unsafe-call": 0, "@typescript-eslint/no-unsafe-return": 0, "@typescript-eslint/prefer-includes": 0, "@typescript-eslint/prefer-optional-chain": 0, "@typescript-eslint/prefer-nullish-coalescing": 0, "@typescript-eslint/restrict-plus-operands": 0 }, "globals": [ "window", "VERSION" ] }, "devEngines": { "runtime": { "name": "node", "version": ">=20", "onFail": "warn" } }, "optionalDependencies": { "@types/trusted-types": "^2.0.7" }, "devDependencies": { "@babel/core": "^7.17.8", "@babel/preset-env": "^7.16.11", "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-node-resolve": "^15.3.0", "@rollup/plugin-replace": "^6.0.1", "@rollup/plugin-terser": "^1.0.0", "@types/estree": "^1.0.0", "@types/node": "^16.18.120", "cross-env": "^7.0.3", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.0.0", "jquery": "^3.6.0", "jsdom": "^28.1.0", "karma": "^6.3.17", "karma-browserstack-launcher": "^1.5.1", "karma-chrome-launcher": "^3.1.0", "karma-firefox-launcher": "^2.1.2", "karma-qunit": "^4.1.2", "karma-rollup-preprocessor": "^7.0.8", "minimist": "^1.2.6", "pre-commit": "^1.2.2", "prettier": "^2.5.1", "qunit": "^2.4.1", "qunit-tap": "^1.5.0", "rimraf": "^3.0.2", "rollup": "^3.30.0", "rollup-plugin-dts": "^6.1.1", "rollup-plugin-includepaths": "^0.2.4", "rollup-plugin-typescript2": "^0.36.0", "tslib": "^2.7.0", "typescript": "^5.6.3", "xo": "^0.54.1" }, "resolutions": { "natives": "1.1.6" }, "name": "dompurify", "description": "DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. It's written in JavaScript and works in all modern browsers (Safari, Opera (15+), Internet Explorer (10+), Firefox and Chrome - as well as almost anything else using Blink or WebKit). DOMPurify is written by security people who have vast background in web attacks and XSS. Fear not.", "version": "3.3.3", "directories": { "test": "test" }, "repository": { "type": "git", "url": "git://github.com/cure53/DOMPurify.git" }, "keywords": [ "dom", "xss", "html", "svg", "mathml", "security", "secure", "sanitizer", "sanitize", "filter", "purify" ], "author": "Dr.-Ing. Mario Heiderich, Cure53 (https://cure53.de/)", "license": "(MPL-2.0 OR Apache-2.0)", "bugs": { "url": "https://github.com/cure53/DOMPurify/issues" }, "homepage": "https://github.com/cure53/DOMPurify" } ================================================ FILE: rollup.config.js ================================================ const fs = require('fs'); const { DEFAULT_EXTENSIONS } = require('@babel/core'); const babel = require('@rollup/plugin-babel').babel; const nodeResolve = require('@rollup/plugin-node-resolve').nodeResolve; const replace = require('@rollup/plugin-replace'); const terser = require('@rollup/plugin-terser'); const typescript = require('rollup-plugin-typescript2'); const { dts } = require('rollup-plugin-dts'); const pkg = require('./package.json'); const env = process.env.NODE_ENV; const version = process.env.npm_package_version; const license = fs .readFileSync('./src/license_header', 'utf8') .replace(/VERSION/gi, version); const commonOutputConfig = { name: 'DOMPurify', sourcemap: true, banner: license, exports: 'default', }; // 🔧 Plugin to strip named type exports from .d.ts for CommonJS const stripNamedTypeExports = () => ({ name: 'strip-named-type-exports', transform(code, id) { if (id.endsWith('.d.ts')) { return { code: code.replace(/^export\s+\{\s*type[\s\S]+?^\};\s*$/gm, ''), map: null, }; } }, }); const config = [ { input: 'src/purify.ts', external: [], output: [ { ...commonOutputConfig, file: pkg.browser, format: 'umd', }, { ...commonOutputConfig, file: pkg.production, format: 'umd', plugins: [terser()], }, { ...commonOutputConfig, file: pkg.module, format: 'es', }, { ...commonOutputConfig, file: pkg.main, format: 'cjs', }, ], plugins: [ typescript({ clean: true, }), babel({ babelHelpers: 'bundled', exclude: ['**/node_modules/**'], extensions: [...DEFAULT_EXTENSIONS, '.ts'], }), nodeResolve(), replace({ preventAssignment: true, values: { 'process.env.NODE_ENV': JSON.stringify(env), VERSION: `'${version}'`, }, }), ], }, // ESM type declarations { input: './dist/types/purify.d.ts', output: [ { file: pkg.module.replace(/\.mjs$/, '.d.mts'), format: 'es', banner: commonOutputConfig.banner, }, ], plugins: [dts()], }, // CJS type declarations with named export stripping { input: './dist/types/purify.d.ts', output: [ { file: pkg.main.replace(/\.js$/, '.d.ts'), format: 'cjs', banner: commonOutputConfig.banner, }, ], plugins: [ stripNamedTypeExports(), dts(), ], }, ]; module.exports = config; ================================================ FILE: scripts/commit-amend-build.sh ================================================ echo "# Amending minified assets to HEAD" git add ./dist/purify.js ./dist/purify.js.map ./dist/purify.min.js ./dist/purify.min.js.map ./dist/purify.cjs.js ./dist/purify.cjs.js.map ./dist/purify.cjs.d.ts ./dist/purify.es.mjs ./dist/purify.es.mjs.map ./dist/purify.es.d.mts ================================================ FILE: scripts/fix-types.js ================================================ // @ts-check const fs = require('node:fs/promises'); const path = require('node:path'); (async () => { // Note that this script is intended to run on the type declaration file that is // output by Rollup, and not the type declaration file generated from TypeScript. await fixCjsTypes(path.resolve(__dirname, '../dist/purify.cjs.d.ts')); })().catch((ex) => { console.error(ex); process.exitCode = 1; }); /** * Fixes the CommonJS type declarations file. * @param {string} fileName */ async function fixCjsTypes(fileName) { try { // 1. Read the generated type file let types = await fs.readFile(fileName, { encoding: 'utf-8' }); // 2. Remove the ESM-style default exports. // We use Regex to handle the variation your compiler is producing. let fixed = types .replace(/export default _default;/g, '') .replace(/, _default as default/g, ''); // 3. Append the CommonJS-friendly export. // This is the "fix" that allows require('dompurify') to work with TS. fixed += '\n// @ts-ignore\nexport = _default;\n'; // 4. Write the file back to the dist folder await fs.writeFile(fileName, fixed); } catch (err) { // We catch the error but don't re-throw it. // This ensures 'npm run build' continues even if this step hiccups. console.warn(`Warning: Could not patch ${fileName}. Error: ${err.message}`); } } ================================================ FILE: src/attrs.ts ================================================ import { freeze } from './utils.js'; export const html = freeze([ 'accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot', ] as const); export const svg = freeze([ 'accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan', ] as const); export const mathMl = freeze([ 'accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns', ]); export const xml = freeze([ 'xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink', ] as const); ================================================ FILE: src/config.ts ================================================ /* eslint-disable @typescript-eslint/indent */ import type { TrustedTypePolicy } from 'trusted-types/lib/index.js'; /** * Configuration to control DOMPurify behavior. */ export interface Config { /** * Extend the existing array of allowed attributes. * Can be an array of attribute names, or a function that receives * the attribute name and tag name to determine if the attribute is allowed. */ ADD_ATTR?: | string[] | ((attributeName: string, tagName: string) => boolean) | undefined; /** * Extend the existing array of elements that can use Data URIs. */ ADD_DATA_URI_TAGS?: string[] | undefined; /** * Extend the existing array of allowed tags. * Can be an array of tag names, or a function that receives * the tag name to determine if the tag is allowed. */ ADD_TAGS?: string[] | ((tagName: string) => boolean) | undefined; /** * Extend the existing array of elements that are safe for URI-like values (be careful, XSS risk). */ ADD_URI_SAFE_ATTR?: string[] | undefined; /** * Allow ARIA attributes, leave other safe HTML as is (default is true). */ ALLOW_ARIA_ATTR?: boolean | undefined; /** * Allow HTML5 data attributes, leave other safe HTML as is (default is true). */ ALLOW_DATA_ATTR?: boolean | undefined; /** * Allow external protocol handlers in URL attributes (default is false, be careful, XSS risk). * By default only `http`, `https`, `ftp`, `ftps`, `tel`, `mailto`, `callto`, `sms`, `cid` and `xmpp` are allowed. */ ALLOW_UNKNOWN_PROTOCOLS?: boolean | undefined; /** * Decide if self-closing tags in attributes are allowed. * Usually removed due to a mXSS issue in jQuery 3.0. */ ALLOW_SELF_CLOSE_IN_ATTR?: boolean | undefined; /** * Allow only specific attributes. */ ALLOWED_ATTR?: string[] | undefined; /** * Allow only specific elements. */ ALLOWED_TAGS?: string[] | undefined; /** * Allow only specific namespaces. Defaults to: * - `http://www.w3.org/1999/xhtml` * - `http://www.w3.org/2000/svg` * - `http://www.w3.org/1998/Math/MathML` */ ALLOWED_NAMESPACES?: string[] | undefined; /** * Allow specific protocols handlers in URL attributes via regex (be careful, XSS risk). * Default RegExp: * ``` * /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i; * ``` */ ALLOWED_URI_REGEXP?: RegExp | undefined; /** * Define how custom elements are handled. */ CUSTOM_ELEMENT_HANDLING?: { /** * Regular expression or function to match to allowed elements. * Default is null (disallow any custom elements). */ tagNameCheck?: RegExp | ((tagName: string) => boolean) | null | undefined; /** * Regular expression or function to match to allowed attributes. * Default is null (disallow any attributes not on the allow list). */ attributeNameCheck?: | RegExp | ((attributeName: string, tagName?: string) => boolean) | null | undefined; /** * Allow custom elements derived from built-ins if they pass `tagNameCheck`. Default is false. */ allowCustomizedBuiltInElements?: boolean | undefined; }; /** * Add attributes to block-list. */ FORBID_ATTR?: string[] | undefined; /** * Add child elements to be removed when their parent is removed. */ FORBID_CONTENTS?: string[] | undefined; /** * Extend the existing or default array of forbidden content elements. */ ADD_FORBID_CONTENTS?: string[] | undefined; /** * Add elements to block-list. */ FORBID_TAGS?: string[] | undefined; /** * Glue elements like style, script or others to `document.body` and prevent unintuitive browser behavior in several edge-cases (default is false). */ FORCE_BODY?: boolean | undefined; /** * Map of non-standard HTML element names to support. Map to true to enable support. For example: * * ``` * HTML_INTEGRATION_POINTS: { foreignobject: true } * ``` */ HTML_INTEGRATION_POINTS?: Record | undefined; /** * Sanitize a node "in place", which is much faster depending on how you use DOMPurify. */ IN_PLACE?: boolean | undefined; /** * Keep an element's content when the element is removed (default is true). */ KEEP_CONTENT?: boolean | undefined; /** * Map of MathML element names to support. Map to true to enable support. For example: * * ``` * MATHML_TEXT_INTEGRATION_POINTS: { mtext: true } * ``` */ MATHML_TEXT_INTEGRATION_POINTS?: Record | undefined; /** * Change the default namespace from HTML to something different. */ NAMESPACE?: string | undefined; /** * Change the parser type so sanitized data is treated as XML and not as HTML, which is the default. */ PARSER_MEDIA_TYPE?: DOMParserSupportedType | undefined; /** * Return a DOM `DocumentFragment` instead of an HTML string (default is false). */ RETURN_DOM_FRAGMENT?: boolean | undefined; /** * Return a DOM `HTMLBodyElement` instead of an HTML string (default is false). */ RETURN_DOM?: boolean | undefined; /** * Return a TrustedHTML object instead of a string if possible. */ RETURN_TRUSTED_TYPE?: boolean | undefined; /** * Strip `{{ ... }}`, `${ ... }` and `<% ... %>` to make output safe for template systems. * Be careful please, this mode is not recommended for production usage. * Allowing template parsing in user-controlled HTML is not advised at all. * Only use this mode if there is really no alternative. */ SAFE_FOR_TEMPLATES?: boolean | undefined; /** * Change how e.g. comments containing risky HTML characters are treated. * Be very careful, this setting should only be set to `false` if you really only handle * HTML and nothing else, no SVG, MathML or the like. * Otherwise, changing from `true` to `false` will lead to XSS in this or some other way. */ SAFE_FOR_XML?: boolean | undefined; /** * Use DOM Clobbering protection on output (default is true, handle with care, minor XSS risks here). */ SANITIZE_DOM?: boolean | undefined; /** * Enforce strict DOM Clobbering protection via namespace isolation (default is false). * When enabled, isolates the namespace of named properties (i.e., `id` and `name` attributes) * from JS variables by prefixing them with the string `user-content-` */ SANITIZE_NAMED_PROPS?: boolean | undefined; /** * Supplied policy must define `createHTML` and `createScriptURL`. */ TRUSTED_TYPES_POLICY?: TrustedTypePolicy | undefined; /** * Controls categories of allowed elements. * * Note that the `USE_PROFILES` setting will override the `ALLOWED_TAGS` setting * so don't use them together. */ USE_PROFILES?: false | UseProfilesConfig | undefined; /** * Return entire document including tags (default is false). */ WHOLE_DOCUMENT?: boolean | undefined; } /** * Defines categories of allowed elements. */ export interface UseProfilesConfig { /** * Allow all safe MathML elements. */ mathMl?: boolean | undefined; /** * Allow all safe SVG elements. */ svg?: boolean | undefined; /** * Allow all save SVG Filters. */ svgFilters?: boolean | undefined; /** * Allow all safe HTML elements. */ html?: boolean | undefined; } ================================================ FILE: src/license_header ================================================ /*! @license DOMPurify VERSION | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/VERSION/LICENSE */ ================================================ FILE: src/purify.ts ================================================ /* eslint-disable @typescript-eslint/indent */ import type { TrustedHTML, TrustedTypesWindow, } from 'trusted-types/lib/index.js'; import type { Config, UseProfilesConfig } from './config'; import * as TAGS from './tags.js'; import * as ATTRS from './attrs.js'; import * as EXPRESSIONS from './regexp.js'; import { addToSet, clone, entries, freeze, arrayForEach, arrayLastIndexOf, arrayPop, arrayPush, arraySplice, stringMatch, stringReplace, stringToLowerCase, stringToString, stringIndexOf, stringTrim, regExpTest, typeErrorCreate, lookupGetter, create, objectHasOwnProperty, } from './utils.js'; export type { Config } from './config'; declare const VERSION: string; // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType const NODE_TYPE = { element: 1, attribute: 2, text: 3, cdataSection: 4, entityReference: 5, // Deprecated entityNode: 6, // Deprecated progressingInstruction: 7, comment: 8, document: 9, documentType: 10, documentFragment: 11, notation: 12, // Deprecated }; const getGlobal = function (): WindowLike { return typeof window === 'undefined' ? null : window; }; /** * Creates a no-op policy for internal use only. * Don't export this function outside this module! * @param trustedTypes The policy factory. * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix). * @return The policy created (or null, if Trusted Types * are not supported or creating the policy failed). */ const _createTrustedTypesPolicy = function ( trustedTypes: TrustedTypePolicyFactory, purifyHostElement: HTMLScriptElement ) { if ( typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function' ) { return null; } // Allow the callers to control the unique policy name // by adding a data-tt-policy-suffix to the script element with the DOMPurify. // Policy creation with duplicate names throws in Trusted Types. let suffix = null; const ATTR_NAME = 'data-tt-policy-suffix'; if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) { suffix = purifyHostElement.getAttribute(ATTR_NAME); } const policyName = 'dompurify' + (suffix ? '#' + suffix : ''); try { return trustedTypes.createPolicy(policyName, { createHTML(html) { return html; }, createScriptURL(scriptUrl) { return scriptUrl; }, }); } catch (_) { // Policy creation failed (most likely another DOMPurify script has // already run). Skip creating the policy, as this will only cause errors // if TT are enforced. console.warn( 'TrustedTypes policy ' + policyName + ' could not be created.' ); return null; } }; const _createHooksMap = function (): HooksMap { return { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [], }; }; function createDOMPurify(window: WindowLike = getGlobal()): DOMPurify { const DOMPurify: DOMPurify = (root: WindowLike) => createDOMPurify(root); DOMPurify.version = VERSION; DOMPurify.removed = []; if ( !window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element ) { // Not running in a browser, provide a factory function // so that you can pass your own Window DOMPurify.isSupported = false; return DOMPurify; } let { document } = window; const originalDocument = document; const currentScript: HTMLScriptElement = originalDocument.currentScript as HTMLScriptElement; const { DocumentFragment, HTMLTemplateElement, Node, Element, NodeFilter, NamedNodeMap = window.NamedNodeMap || (window as any).MozNamedAttrMap, HTMLFormElement, DOMParser, trustedTypes, } = window; const ElementPrototype = Element.prototype; const cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); const remove = lookupGetter(ElementPrototype, 'remove'); const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); const getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a // new document created via createHTMLDocument. As per the spec // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) // a new empty registry is used when creating a template contents owner // document, so we use that as our parent document to ensure nothing // is inherited. if (typeof HTMLTemplateElement === 'function') { const template = document.createElement('template'); if (template.content && template.content.ownerDocument) { document = template.content.ownerDocument; } } let trustedTypesPolicy; let emptyHTML = ''; const { implementation, createNodeIterator, createDocumentFragment, getElementsByTagName, } = document; const { importNode } = originalDocument; let hooks = _createHooksMap(); /** * Expose whether this browser supports running the full DOMPurify. */ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined; const { MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR, DATA_ATTR, ARIA_ATTR, IS_SCRIPT_OR_DATA, ATTR_WHITESPACE, CUSTOM_ELEMENT, } = EXPRESSIONS; let { IS_ALLOWED_URI } = EXPRESSIONS; /** * We consider the elements and attributes below to be safe. Ideally * don't add any new ones but feel free to remove unwanted ones. */ /* allowed element names */ let ALLOWED_TAGS = null; const DEFAULT_ALLOWED_TAGS = addToSet({}, [ ...TAGS.html, ...TAGS.svg, ...TAGS.svgFilters, ...TAGS.mathMl, ...TAGS.text, ]); /* Allowed attribute names */ let ALLOWED_ATTR = null; const DEFAULT_ALLOWED_ATTR = addToSet({}, [ ...ATTRS.html, ...ATTRS.svg, ...ATTRS.mathMl, ...ATTRS.xml, ]); /* * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements. * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements) * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list) * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`. */ let CUSTOM_ELEMENT_HANDLING = Object.seal( create(null, { tagNameCheck: { writable: true, configurable: false, enumerable: true, value: null, }, attributeNameCheck: { writable: true, configurable: false, enumerable: true, value: null, }, allowCustomizedBuiltInElements: { writable: true, configurable: false, enumerable: true, value: false, }, }) ); /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ let FORBID_TAGS = null; /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ let FORBID_ATTR = null; /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */ const EXTRA_ELEMENT_HANDLING = Object.seal( create(null, { tagCheck: { writable: true, configurable: false, enumerable: true, value: null, }, attributeCheck: { writable: true, configurable: false, enumerable: true, value: null, }, }) ); /* Decide if ARIA attributes are okay */ let ALLOW_ARIA_ATTR = true; /* Decide if custom data attributes are okay */ let ALLOW_DATA_ATTR = true; /* Decide if unknown protocols are okay */ let ALLOW_UNKNOWN_PROTOCOLS = false; /* Decide if self-closing tags in attributes are allowed. * Usually removed due to a mXSS issue in jQuery 3.0 */ let ALLOW_SELF_CLOSE_IN_ATTR = true; /* Output should be safe for common template engines. * This means, DOMPurify removes data attributes, mustaches and ERB */ let SAFE_FOR_TEMPLATES = false; /* Output should be safe even for XML used within HTML and alike. * This means, DOMPurify removes comments when containing risky content. */ let SAFE_FOR_XML = true; /* Decide if document with ... should be returned */ let WHOLE_DOCUMENT = false; /* Track whether config is already set on this instance of DOMPurify. */ let SET_CONFIG = false; /* Decide if all elements (e.g. style, script) must be children of * document.body. By default, browsers might move them to document.head */ let FORCE_BODY = false; /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html * string (or a TrustedHTML object if Trusted Types are supported). * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead */ let RETURN_DOM = false; /* Decide if a DOM `DocumentFragment` should be returned, instead of a html * string (or a TrustedHTML object if Trusted Types are supported) */ let RETURN_DOM_FRAGMENT = false; /* Try to return a Trusted Type object instead of a string, return a string in * case Trusted Types are not supported */ let RETURN_TRUSTED_TYPE = false; /* Output should be free from DOM clobbering attacks? * This sanitizes markups named with colliding, clobberable built-in DOM APIs. */ let SANITIZE_DOM = true; /* Achieve full DOM Clobbering protection by isolating the namespace of named * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules. * * HTML/DOM spec rules that enable DOM Clobbering: * - Named Access on Window (§7.3.3) * - DOM Tree Accessors (§3.1.5) * - Form Element Parent-Child Relations (§4.10.3) * - Iframe srcdoc / Nested WindowProxies (§4.8.5) * - HTMLCollection (§4.2.10.2) * * Namespace isolation is implemented by prefixing `id` and `name` attributes * with a constant string, i.e., `user-content-` */ let SANITIZE_NAMED_PROPS = false; const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-'; /* Keep element content when removing element? */ let KEEP_CONTENT = true; /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead * of importing it into a new Document and returning a sanitized copy */ let IN_PLACE = false; /* Allow usage of profiles like html, svg and mathMl */ let USE_PROFILES: UseProfilesConfig | false = {}; /* Tags to ignore content of when KEEP_CONTENT is true */ let FORBID_CONTENTS = null; const DEFAULT_FORBID_CONTENTS = addToSet({}, [ 'annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp', ]); /* Tags that are safe for data: URIs */ let DATA_URI_TAGS = null; const DEFAULT_DATA_URI_TAGS = addToSet({}, [ 'audio', 'video', 'img', 'source', 'image', 'track', ]); /* Attributes safe for values like "javascript:" */ let URI_SAFE_ATTRIBUTES = null; const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [ 'alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns', ]); const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; /* Document namespace */ let NAMESPACE = HTML_NAMESPACE; let IS_EMPTY_INPUT = false; /* Allowed XHTML+XML namespaces */ let ALLOWED_NAMESPACES = null; const DEFAULT_ALLOWED_NAMESPACES = addToSet( {}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString ); let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, [ 'mi', 'mo', 'mn', 'ms', 'mtext', ]); let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']); // Certain elements are allowed in both SVG and HTML // namespace. We need to specify them explicitly // so that they don't get erroneously deleted from // HTML namespace. const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [ 'title', 'style', 'font', 'a', 'script', ]); /* Parsing of strict XHTML documents */ let PARSER_MEDIA_TYPE: null | DOMParserSupportedType = null; const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; const DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; let transformCaseFunc: null | Parameters[2] = null; /* Keep a reference to config to pass to hooks */ let CONFIG: Config | null = null; /* Ideally, do not touch anything below this line */ /* ______________________________________________ */ const formElement = document.createElement('form'); const isRegexOrFunction = function ( testValue: unknown ): testValue is Function | RegExp { return testValue instanceof RegExp || testValue instanceof Function; }; /** * _parseConfig * * @param cfg optional config literal */ // eslint-disable-next-line complexity const _parseConfig = function (cfg: Config = {}): void { if (CONFIG && CONFIG === cfg) { return; } /* Shield configuration object from tampering */ if (!cfg || typeof cfg !== 'object') { cfg = {}; } /* Shield configuration object from prototype pollution */ cfg = clone(cfg); PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase; /* Set configuration parameters */ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS; ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR; ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES; URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet( clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc ) : DEFAULT_URI_SAFE_ATTRIBUTES; DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet( clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc ) : DEFAULT_DATA_URI_TAGS; FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS; FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({}); FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({}); USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false; ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false RETURN_DOM = cfg.RETURN_DOM || false; // Default false RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false FORCE_BODY = cfg.FORCE_BODY || false; // Default false SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true IN_PLACE = cfg.IN_PLACE || false; // Default false IS_ALLOWED_URI = cfg.ALLOWED_URI_REGEXP || EXPRESSIONS.IS_ALLOWED_URI; NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS; HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS; CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {}; if ( cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck) ) { CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; } if ( cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) ) { CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck; } if ( cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean' ) { CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements; } if (SAFE_FOR_TEMPLATES) { ALLOW_DATA_ATTR = false; } if (RETURN_DOM_FRAGMENT) { RETURN_DOM = true; } /* Parse profile info */ if (USE_PROFILES) { ALLOWED_TAGS = addToSet({}, TAGS.text); ALLOWED_ATTR = create(null); if (USE_PROFILES.html === true) { addToSet(ALLOWED_TAGS, TAGS.html); addToSet(ALLOWED_ATTR, ATTRS.html); } if (USE_PROFILES.svg === true) { addToSet(ALLOWED_TAGS, TAGS.svg); addToSet(ALLOWED_ATTR, ATTRS.svg); addToSet(ALLOWED_ATTR, ATTRS.xml); } if (USE_PROFILES.svgFilters === true) { addToSet(ALLOWED_TAGS, TAGS.svgFilters); addToSet(ALLOWED_ATTR, ATTRS.svg); addToSet(ALLOWED_ATTR, ATTRS.xml); } if (USE_PROFILES.mathMl === true) { addToSet(ALLOWED_TAGS, TAGS.mathMl); addToSet(ALLOWED_ATTR, ATTRS.mathMl); addToSet(ALLOWED_ATTR, ATTRS.xml); } } /* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */ if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) { EXTRA_ELEMENT_HANDLING.tagCheck = null; } if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) { EXTRA_ELEMENT_HANDLING.attributeCheck = null; } /* Merge configuration parameters */ if (cfg.ADD_TAGS) { if (typeof cfg.ADD_TAGS === 'function') { EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS; } else { if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { ALLOWED_TAGS = clone(ALLOWED_TAGS); } addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc); } } if (cfg.ADD_ATTR) { if (typeof cfg.ADD_ATTR === 'function') { EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR; } else { if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { ALLOWED_ATTR = clone(ALLOWED_ATTR); } addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc); } } if (cfg.ADD_URI_SAFE_ATTR) { addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc); } if (cfg.FORBID_CONTENTS) { if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { FORBID_CONTENTS = clone(FORBID_CONTENTS); } addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc); } if (cfg.ADD_FORBID_CONTENTS) { if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { FORBID_CONTENTS = clone(FORBID_CONTENTS); } addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc); } /* Add #text in case KEEP_CONTENT is set to true */ if (KEEP_CONTENT) { ALLOWED_TAGS['#text'] = true; } /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ if (WHOLE_DOCUMENT) { addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); } /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ if (ALLOWED_TAGS.table) { addToSet(ALLOWED_TAGS, ['tbody']); delete FORBID_TAGS.tbody; } if (cfg.TRUSTED_TYPES_POLICY) { if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') { throw typeErrorCreate( 'TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.' ); } if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') { throw typeErrorCreate( 'TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.' ); } // Overwrite existing TrustedTypes policy. trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; // Sign local variables required by `sanitize`. emptyHTML = trustedTypesPolicy.createHTML(''); } else { // Uninitialized policy, attempt to initialize the internal dompurify policy. if (trustedTypesPolicy === undefined) { trustedTypesPolicy = _createTrustedTypesPolicy( trustedTypes, currentScript ); } // If creating the internal policy succeeded sign internal variables. if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') { emptyHTML = trustedTypesPolicy.createHTML(''); } } // Prevent further manipulation of configuration. // Not available in IE8, Safari 5, etc. if (freeze) { freeze(cfg); } CONFIG = cfg; }; /* Keep track of all possible SVG and MathML tags * so that we can perform the namespace checks * correctly. */ const ALL_SVG_TAGS = addToSet({}, [ ...TAGS.svg, ...TAGS.svgFilters, ...TAGS.svgDisallowed, ]); const ALL_MATHML_TAGS = addToSet({}, [ ...TAGS.mathMl, ...TAGS.mathMlDisallowed, ]); /** * @param element a DOM element whose namespace is being checked * @returns Return false if the element has a * namespace that a spec-compliant parser would never * return. Return true otherwise. */ const _checkValidNamespace = function (element: Element): boolean { let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode // can be null. We just simulate parent in this case. if (!parent || !parent.tagName) { parent = { namespaceURI: NAMESPACE, tagName: 'template', }; } const tagName = stringToLowerCase(element.tagName); const parentTagName = stringToLowerCase(parent.tagName); if (!ALLOWED_NAMESPACES[element.namespaceURI]) { return false; } if (element.namespaceURI === SVG_NAMESPACE) { // The only way to switch from HTML namespace to SVG // is via . If it happens via any other tag, then // it should be killed. if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === 'svg'; } // The only way to switch from MathML to SVG is via` // svg if parent is either or MathML // text integration points. if (parent.namespaceURI === MATHML_NAMESPACE) { return ( tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) ); } // We only allow elements that are defined in SVG // spec. All others are disallowed in SVG namespace. return Boolean(ALL_SVG_TAGS[tagName]); } if (element.namespaceURI === MATHML_NAMESPACE) { // The only way to switch from HTML namespace to MathML // is via . If it happens via any other tag, then // it should be killed. if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === 'math'; } // The only way to switch from SVG to MathML is via // and HTML integration points if (parent.namespaceURI === SVG_NAMESPACE) { return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; } // We only allow elements that are defined in MathML // spec. All others are disallowed in MathML namespace. return Boolean(ALL_MATHML_TAGS[tagName]); } if (element.namespaceURI === HTML_NAMESPACE) { // The only way to switch from SVG to HTML is via // HTML integration points, and from MathML to HTML // is via MathML text integration points if ( parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName] ) { return false; } if ( parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName] ) { return false; } // We disallow tags that are specific for MathML // or SVG and should never appear in HTML namespace return ( !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]) ); } // For XHTML and XML documents that support custom namespaces if ( PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI] ) { return true; } // The code should never reach this place (this means // that the element somehow got namespace that is not // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES). // Return false just in case. return false; }; /** * _forceRemove * * @param node a DOM node */ const _forceRemove = function (node: Node): void { arrayPush(DOMPurify.removed, { element: node }); try { // eslint-disable-next-line unicorn/prefer-dom-node-remove getParentNode(node).removeChild(node); } catch (_) { remove(node); } }; /** * _removeAttribute * * @param name an Attribute name * @param element a DOM node */ const _removeAttribute = function (name: string, element: Element): void { try { arrayPush(DOMPurify.removed, { attribute: element.getAttributeNode(name), from: element, }); } catch (_) { arrayPush(DOMPurify.removed, { attribute: null, from: element, }); } element.removeAttribute(name); // We void attribute values for unremovable "is" attributes if (name === 'is') { if (RETURN_DOM || RETURN_DOM_FRAGMENT) { try { _forceRemove(element); } catch (_) {} } else { try { element.setAttribute(name, ''); } catch (_) {} } } }; /** * _initDocument * * @param dirty - a string of dirty markup * @return a DOM, filled with the dirty markup */ const _initDocument = function (dirty: string): Document { /* Create a HTML document */ let doc = null; let leadingWhitespace = null; if (FORCE_BODY) { dirty = '' + dirty; } else { /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ const matches = stringMatch(dirty, /^[\r\n\t ]+/); leadingWhitespace = matches && matches[0]; } if ( PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE ) { // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict) dirty = '' + dirty + ''; } const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; /* * Use the DOMParser API by default, fallback later if needs be * DOMParser not work for svg when has multiple root element. */ if (NAMESPACE === HTML_NAMESPACE) { try { doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); } catch (_) {} } /* Use createHTMLDocument in case DOMParser is not available */ if (!doc || !doc.documentElement) { doc = implementation.createDocument(NAMESPACE, 'template', null); try { doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload; } catch (_) { // Syntax error if dirtyPayload is invalid xml } } const body = doc.body || doc.documentElement; if (dirty && leadingWhitespace) { body.insertBefore( document.createTextNode(leadingWhitespace), body.childNodes[0] || null ); } /* Work on whole document or just its body */ if (NAMESPACE === HTML_NAMESPACE) { return getElementsByTagName.call( doc, WHOLE_DOCUMENT ? 'html' : 'body' )[0]; } return WHOLE_DOCUMENT ? doc.documentElement : body; }; /** * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. * * @param root The root element or node to start traversing on. * @return The created NodeIterator */ const _createNodeIterator = function (root: Node): NodeIterator { return createNodeIterator.call( root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null ); }; /** * _isClobbered * * @param element element to check for clobbering attacks * @return true if clobbered, false if safe */ const _isClobbered = function (element: Element): boolean { return ( element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function') ); }; /** * Checks whether the given object is a DOM node. * * @param value object to check whether it's a DOM node * @return true is object is a DOM node */ const _isNode = function (value: unknown): value is Node { return typeof Node === 'function' && value instanceof Node; }; function _executeHooks( hooks: HookFunction[], currentNode: Parameters[0], data: Parameters[1] ): void { arrayForEach(hooks, (hook: T) => { hook.call(DOMPurify, currentNode, data, CONFIG); }); } /** * _sanitizeElements * * @protect nodeName * @protect textContent * @protect removeChild * @param currentNode to check for permission to exist * @return true if node was killed, false if left alive */ const _sanitizeElements = function (currentNode: any): boolean { let content = null; /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeElements, currentNode, null); /* Check if element is clobbered or can clobber */ if (_isClobbered(currentNode)) { _forceRemove(currentNode); return true; } /* Now let's check the element's type and name */ const tagName = transformCaseFunc(currentNode.nodeName); /* Execute a hook if present */ _executeHooks(hooks.uponSanitizeElement, currentNode, { tagName, allowedTags: ALLOWED_TAGS, }); /* Detect mXSS attempts abusing namespace confusion */ if ( SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent) ) { _forceRemove(currentNode); return true; } /* Remove any occurrence of processing instructions */ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) { _forceRemove(currentNode); return true; } /* Remove any kind of possibly harmful comments */ if ( SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data) ) { _forceRemove(currentNode); return true; } /* Remove element if anything forbids its presence */ if ( !( EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName) ) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) ) { /* Check if we have a custom element to handle */ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) { if ( CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName) ) { return false; } if ( CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName) ) { return false; } } /* Keep content except for bad-listed elements */ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { const parentNode = getParentNode(currentNode) || currentNode.parentNode; const childNodes = getChildNodes(currentNode) || currentNode.childNodes; if (childNodes && parentNode) { const childCount = childNodes.length; for (let i = childCount - 1; i >= 0; --i) { const childClone = cloneNode(childNodes[i], true); childClone.__removalCount = (currentNode.__removalCount || 0) + 1; parentNode.insertBefore(childClone, getNextSibling(currentNode)); } } } _forceRemove(currentNode); return true; } /* Check whether element has a valid namespace */ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { _forceRemove(currentNode); return true; } /* Make sure that older browsers don't get fallback-tag mXSS */ if ( (tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML) ) { _forceRemove(currentNode); return true; } /* Sanitize element content to be template-safe */ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) { /* Get the element's text content */ content = currentNode.textContent; arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr: RegExp) => { content = stringReplace(content, expr, ' '); }); if (currentNode.textContent !== content) { arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); currentNode.textContent = content; } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeElements, currentNode, null); return false; }; /** * _isValidAttribute * * @param lcTag Lowercase tag name of containing element. * @param lcName Lowercase attribute name. * @param value Attribute value. * @return Returns true if `value` is valid, otherwise false. */ // eslint-disable-next-line complexity const _isValidAttribute = function ( lcTag: string, lcName: string, value: string ): boolean { /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */ if (FORBID_ATTR[lcName]) { return false; } /* Make sure attribute cannot clobber */ if ( SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement) ) { return false; } /* Allow valid data-* attributes: At least one character after "-" (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) We don't need to check the value; it's always URI safe. */ if ( ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName) ) { // This attribute is safe } else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) { // This attribute is safe /* Check if ADD_ATTR function allows this attribute */ } else if ( EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag) ) { // This attribute is safe /* Otherwise, check the name is permitted */ } else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck (_isBasicCustomElement(lcTag) && ((CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag)) || (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag))) && ((CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName)) || (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)))) || // Alternative, second condition checks if it's an `is`-attribute, AND // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck (lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && ((CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value)) || (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value)))) ) { // If user has supplied a regexp or function in CUSTOM_ELEMENT_HANDLING.tagNameCheck, we need to also allow derived custom elements using the same tagName test. // Additionally, we need to allow attributes passing the CUSTOM_ELEMENT_HANDLING.attributeNameCheck user has configured, as custom elements can define these at their own discretion. } else { return false; } /* Check value is safe. First, is attr inert? If so, is safe */ } else if (URI_SAFE_ATTRIBUTES[lcName]) { // This attribute is safe /* Check no script, data or unknown possibly unsafe URI unless we know URI values are safe for that attribute */ } else if ( regExpTest(IS_ALLOWED_URI, stringReplace(value, ATTR_WHITESPACE, '')) ) { // This attribute is safe /* Keep image data URIs alive if src/xlink:href is allowed */ /* Further prevent gadget XSS for dynamically built script tags */ } else if ( (lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag] ) { // This attribute is safe /* Allow unknown protocols: This provides support for links that are handled by protocol handlers which may be unknown ahead of time, e.g. fb:, spotify: */ } else if ( ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, '')) ) { // This attribute is safe /* Check for binary attributes */ } else if (value) { return false; } else { // Binary attributes are safe at this point /* Anything else, presume unsafe, do not add it back */ } return true; }; /** * _isBasicCustomElement * checks if at least one dash is included in tagName, and it's not the first char * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name * * @param tagName name of the tag of the node to sanitize * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false. */ const _isBasicCustomElement = function (tagName: string): RegExpMatchArray { return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT); }; /** * _sanitizeAttributes * * @protect attributes * @protect nodeName * @protect removeAttribute * @protect setAttribute * * @param currentNode to sanitize */ const _sanitizeAttributes = function (currentNode: Element): void { /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null); const { attributes } = currentNode; /* Check if we have attributes; if not we might have a text node */ if (!attributes || _isClobbered(currentNode)) { return; } const hookEvent = { attrName: '', attrValue: '', keepAttr: true, allowedAttributes: ALLOWED_ATTR, forceKeepAttr: undefined, }; let l = attributes.length; /* Go backwards over all attributes; safely remove bad ones */ while (l--) { const attr = attributes[l]; const { name, namespaceURI, value: attrValue } = attr; const lcName = transformCaseFunc(name); const initValue = attrValue; let value = name === 'value' ? initValue : stringTrim(initValue); /* Execute a hook if present */ hookEvent.attrName = lcName; hookEvent.attrValue = value; hookEvent.keepAttr = true; hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent); value = hookEvent.attrValue; /* Full DOM Clobbering protection via namespace isolation, * Prefix id and name attributes with `user-content-` */ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) { // Remove the attribute with this value _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value value = SANITIZE_NAMED_PROPS_PREFIX + value; } /* Work around a security issue with comments inside attributes */ if ( SAFE_FOR_XML && regExpTest( /((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value ) ) { _removeAttribute(name, currentNode); continue; } /* Make sure we cannot easily use animated hrefs, even if animations are allowed */ if (lcName === 'attributename' && stringMatch(value, 'href')) { _removeAttribute(name, currentNode); continue; } /* Did the hooks approve of the attribute? */ if (hookEvent.forceKeepAttr) { continue; } /* Did the hooks approve of the attribute? */ if (!hookEvent.keepAttr) { _removeAttribute(name, currentNode); continue; } /* Work around a security issue in jQuery 3.0 */ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) { _removeAttribute(name, currentNode); continue; } /* Sanitize attribute content to be template-safe */ if (SAFE_FOR_TEMPLATES) { arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr: RegExp) => { value = stringReplace(value, expr, ' '); }); } /* Is `value` valid for this attribute? */ const lcTag = transformCaseFunc(currentNode.nodeName); if (!_isValidAttribute(lcTag, lcName, value)) { _removeAttribute(name, currentNode); continue; } /* Handle attributes that require Trusted Types */ if ( trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' ) { if (namespaceURI) { /* Namespaces are not yet supported, see https://bugs.chromium.org/p/chromium/issues/detail?id=1305293 */ } else { switch (trustedTypes.getAttributeType(lcTag, lcName)) { case 'TrustedHTML': { value = trustedTypesPolicy.createHTML(value); break; } case 'TrustedScriptURL': { value = trustedTypesPolicy.createScriptURL(value); break; } default: { break; } } } } /* Handle invalid data-* attribute set by try-catching it */ if (value !== initValue) { try { if (namespaceURI) { currentNode.setAttributeNS(namespaceURI, name, value); } else { /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ currentNode.setAttribute(name, value); } if (_isClobbered(currentNode)) { _forceRemove(currentNode); } else { arrayPop(DOMPurify.removed); } } catch (_) { _removeAttribute(name, currentNode); } } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null); }; /** * _sanitizeShadowDOM * * @param fragment to iterate over recursively */ const _sanitizeShadowDOM = function (fragment: DocumentFragment): void { let shadowNode = null; const shadowIterator = _createNodeIterator(fragment); /* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null); while ((shadowNode = shadowIterator.nextNode())) { /* Execute a hook if present */ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null); /* Sanitize tags and elements */ _sanitizeElements(shadowNode); /* Check attributes next */ _sanitizeAttributes(shadowNode); /* Deep shadow DOM detected */ if (shadowNode.content instanceof DocumentFragment) { _sanitizeShadowDOM(shadowNode.content); } } /* Execute a hook if present */ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null); }; // eslint-disable-next-line complexity DOMPurify.sanitize = function (dirty, cfg = {}) { let body = null; let importedNode = null; let currentNode = null; let returnNode = null; /* Make sure we have a string to sanitize. DO NOT return early, as this will return the wrong type if the user has requested a DOM object rather than a string */ IS_EMPTY_INPUT = !dirty; if (IS_EMPTY_INPUT) { dirty = ''; } /* Stringify, in case dirty is an object */ if (typeof dirty !== 'string' && !_isNode(dirty)) { if (typeof dirty.toString === 'function') { dirty = dirty.toString(); if (typeof dirty !== 'string') { throw typeErrorCreate('dirty is not a string, aborting'); } } else { throw typeErrorCreate('toString is not a function'); } } /* Return dirty HTML if DOMPurify cannot run */ if (!DOMPurify.isSupported) { return dirty; } /* Assign config vars */ if (!SET_CONFIG) { _parseConfig(cfg); } /* Clean up removed elements */ DOMPurify.removed = []; /* Check if dirty is correctly typed for IN_PLACE */ if (typeof dirty === 'string') { IN_PLACE = false; } if (IN_PLACE) { /* Do some early pre-sanitization to avoid unsafe root nodes */ if ((dirty as Node).nodeName) { const tagName = transformCaseFunc((dirty as Node).nodeName); if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { throw typeErrorCreate( 'root node is forbidden and cannot be sanitized in-place' ); } } } else if (dirty instanceof Node) { /* If dirty is a DOM element, append to an empty document to avoid elements being stripped by the parser */ body = _initDocument(''); importedNode = body.ownerDocument.importNode(dirty, true); if ( importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY' ) { /* Node is already a body, use as is */ body = importedNode; } else if (importedNode.nodeName === 'HTML') { body = importedNode; } else { // eslint-disable-next-line unicorn/prefer-dom-node-append body.appendChild(importedNode); } } else { /* Exit directly if we have nothing to do */ if ( !RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes dirty.indexOf('<') === -1 ) { return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; } /* Initialize the document to work on */ body = _initDocument(dirty); /* Check we have a DOM node from the data */ if (!body) { return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; } } /* Remove first element node (ours) if FORCE_BODY is set */ if (body && FORCE_BODY) { _forceRemove(body.firstChild); } /* Get node iterator */ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body); /* Now start iterating over the created document */ while ((currentNode = nodeIterator.nextNode())) { /* Sanitize tags and elements */ _sanitizeElements(currentNode); /* Check attributes next */ _sanitizeAttributes(currentNode); /* Shadow DOM detected, sanitize it */ if (currentNode.content instanceof DocumentFragment) { _sanitizeShadowDOM(currentNode.content); } } /* If we sanitized `dirty` in-place, return it. */ if (IN_PLACE) { return dirty; } /* Return sanitized string or DOM */ if (RETURN_DOM) { if (RETURN_DOM_FRAGMENT) { returnNode = createDocumentFragment.call(body.ownerDocument); while (body.firstChild) { // eslint-disable-next-line unicorn/prefer-dom-node-append returnNode.appendChild(body.firstChild); } } else { returnNode = body; } if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) { /* AdoptNode() is not used because internal state is not reset (e.g. the past names map of a HTMLFormElement), this is safe in theory but we would rather not risk another attack vector. The state that is cloned by importNode() is explicitly defined by the specs. */ returnNode = importNode.call(originalDocument, returnNode, true); } return returnNode; } let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; /* Serialize doctype if allowed */ if ( WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(EXPRESSIONS.DOCTYPE_NAME, body.ownerDocument.doctype.name) ) { serializedHTML = '\n' + serializedHTML; } /* Sanitize final string template-safe */ if (SAFE_FOR_TEMPLATES) { arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr: RegExp) => { serializedHTML = stringReplace(serializedHTML, expr, ' '); }); } return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; }; DOMPurify.setConfig = function (cfg = {}) { _parseConfig(cfg); SET_CONFIG = true; }; DOMPurify.clearConfig = function () { CONFIG = null; SET_CONFIG = false; }; DOMPurify.isValidAttribute = function (tag, attr, value) { /* Initialize shared config vars if necessary. */ if (!CONFIG) { _parseConfig({}); } const lcTag = transformCaseFunc(tag); const lcName = transformCaseFunc(attr); return _isValidAttribute(lcTag, lcName, value); }; DOMPurify.addHook = function ( entryPoint: keyof HooksMap, hookFunction: HookFunction ) { if (typeof hookFunction !== 'function') { return; } arrayPush(hooks[entryPoint], hookFunction); }; DOMPurify.removeHook = function ( entryPoint: keyof HooksMap, hookFunction: HookFunction ) { if (hookFunction !== undefined) { const index = arrayLastIndexOf(hooks[entryPoint], hookFunction); return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0]; } return arrayPop(hooks[entryPoint]); }; DOMPurify.removeHooks = function (entryPoint: keyof HooksMap) { hooks[entryPoint] = []; }; DOMPurify.removeAllHooks = function () { hooks = _createHooksMap(); }; return DOMPurify; } export default createDOMPurify(); export interface DOMPurify { /** * Creates a DOMPurify instance using the given window-like object. Defaults to `window`. */ (root?: WindowLike): DOMPurify; /** * Version label, exposed for easier checks * if DOMPurify is up to date or not */ version: string; /** * Array of elements that DOMPurify removed during sanitation. * Empty if nothing was removed. */ removed: Array; /** * Expose whether this browser supports running the full DOMPurify. */ isSupported: boolean; /** * Set the configuration once. * * @param cfg configuration object */ setConfig(cfg?: Config): void; /** * Removes the configuration. */ clearConfig(): void; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized TrustedHTML. */ sanitize( dirty: string | Node, cfg: Config & { RETURN_TRUSTED_TYPE: true } ): TrustedHTML; /** * Provides core sanitation functionality. * * @param dirty DOM node * @param cfg object * @returns Sanitized DOM node. */ sanitize(dirty: Node, cfg: Config & { IN_PLACE: true }): Node; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized DOM node. */ sanitize(dirty: string | Node, cfg: Config & { RETURN_DOM: true }): Node; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized document fragment. */ sanitize( dirty: string | Node, cfg: Config & { RETURN_DOM_FRAGMENT: true } ): DocumentFragment; /** * Provides core sanitation functionality. * * @param dirty string or DOM node * @param cfg object * @returns Sanitized string. */ sanitize(dirty: string | Node, cfg?: Config): string; /** * Checks if an attribute value is valid. * Uses last set config, if any. Otherwise, uses config defaults. * * @param tag Tag name of containing element. * @param attr Attribute name. * @param value Attribute value. * @returns Returns true if `value` is valid. Otherwise, returns false. */ isValidAttribute(tag: string, attr: string, value: string): boolean; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: BasicHookName, hookFunction: NodeHook): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook(entryPoint: ElementHookName, hookFunction: ElementHook): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook( entryPoint: DocumentFragmentHookName, hookFunction: DocumentFragmentHook ): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook( entryPoint: 'uponSanitizeElement', hookFunction: UponSanitizeElementHook ): void; /** * Adds a DOMPurify hook. * * @param entryPoint entry point for the hook to add * @param hookFunction function to execute */ addHook( entryPoint: 'uponSanitizeAttribute', hookFunction: UponSanitizeAttributeHook ): void; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook( entryPoint: BasicHookName, hookFunction?: NodeHook ): NodeHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook( entryPoint: ElementHookName, hookFunction?: ElementHook ): ElementHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook( entryPoint: DocumentFragmentHookName, hookFunction?: DocumentFragmentHook ): DocumentFragmentHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook( entryPoint: 'uponSanitizeElement', hookFunction?: UponSanitizeElementHook ): UponSanitizeElementHook | undefined; /** * Remove a DOMPurify hook at a given entryPoint * (pops it from the stack of hooks if hook not specified) * * @param entryPoint entry point for the hook to remove * @param hookFunction optional specific hook to remove * @returns removed hook */ removeHook( entryPoint: 'uponSanitizeAttribute', hookFunction?: UponSanitizeAttributeHook ): UponSanitizeAttributeHook | undefined; /** * Removes all DOMPurify hooks at a given entryPoint * * @param entryPoint entry point for the hooks to remove */ removeHooks(entryPoint: HookName): void; /** * Removes all DOMPurify hooks. */ removeAllHooks(): void; } /** * An element removed by DOMPurify. */ export interface RemovedElement { /** * The element that was removed. */ element: Node; } /** * An element removed by DOMPurify. */ export interface RemovedAttribute { /** * The attribute that was removed. */ attribute: Attr | null; /** * The element that the attribute was removed. */ from: Node; } type BasicHookName = | 'beforeSanitizeElements' | 'afterSanitizeElements' | 'uponSanitizeShadowNode'; type ElementHookName = 'beforeSanitizeAttributes' | 'afterSanitizeAttributes'; type DocumentFragmentHookName = | 'beforeSanitizeShadowDOM' | 'afterSanitizeShadowDOM'; type UponSanitizeElementHookName = 'uponSanitizeElement'; type UponSanitizeAttributeHookName = 'uponSanitizeAttribute'; interface HooksMap { beforeSanitizeElements: NodeHook[]; afterSanitizeElements: NodeHook[]; beforeSanitizeShadowDOM: DocumentFragmentHook[]; uponSanitizeShadowNode: NodeHook[]; afterSanitizeShadowDOM: DocumentFragmentHook[]; beforeSanitizeAttributes: ElementHook[]; afterSanitizeAttributes: ElementHook[]; uponSanitizeElement: UponSanitizeElementHook[]; uponSanitizeAttribute: UponSanitizeAttributeHook[]; } type ArrayElement = T extends Array ? U : never; type HookFunction = ArrayElement; export type HookName = | BasicHookName | ElementHookName | DocumentFragmentHookName | UponSanitizeElementHookName | UponSanitizeAttributeHookName; export type NodeHook = ( this: DOMPurify, currentNode: Node, hookEvent: null, config: Config ) => void; export type ElementHook = ( this: DOMPurify, currentNode: Element, hookEvent: null, config: Config ) => void; export type DocumentFragmentHook = ( this: DOMPurify, currentNode: DocumentFragment, hookEvent: null, config: Config ) => void; export type UponSanitizeElementHook = ( this: DOMPurify, currentNode: Node, hookEvent: UponSanitizeElementHookEvent, config: Config ) => void; export type UponSanitizeAttributeHook = ( this: DOMPurify, currentNode: Element, hookEvent: UponSanitizeAttributeHookEvent, config: Config ) => void; export interface UponSanitizeElementHookEvent { tagName: string; allowedTags: Record; } export interface UponSanitizeAttributeHookEvent { attrName: string; attrValue: string; keepAttr: boolean; allowedAttributes: Record; forceKeepAttr: boolean | undefined; } /** * A `Window`-like object containing the properties and types that DOMPurify requires. */ export type WindowLike = Pick< typeof globalThis, | 'DocumentFragment' | 'HTMLTemplateElement' | 'Node' | 'Element' | 'NodeFilter' | 'NamedNodeMap' | 'HTMLFormElement' | 'DOMParser' > & { document?: Document; MozNamedAttrMap?: typeof window.NamedNodeMap; } & Pick; ================================================ FILE: src/regexp.ts ================================================ import { seal } from './utils.js'; // eslint-disable-next-line unicorn/better-regex export const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode export const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); export const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex export const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape export const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape export const IS_ALLOWED_URI = seal( /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape ); export const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); export const ATTR_WHITESPACE = seal( /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex ); export const DOCTYPE_NAME = seal(/^html$/i); export const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i); ================================================ FILE: src/tags.ts ================================================ import { freeze } from './utils.js'; export const html = freeze([ 'a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr', ] as const); export const svg = freeze([ 'svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern', ] as const); export const svgFilters = freeze([ 'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', ] as const); // List of SVG elements that are disallowed by default. // We still need to know them so that we can do namespace // checks properly in case one wants to add them to // allow-list. export const svgDisallowed = freeze([ 'animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use', ] as const); export const mathMl = freeze([ 'math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts', ] as const); // Similarly to SVG, we want to know all MathML elements, // even those that we disallow by default. export const mathMlDisallowed = freeze([ 'maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none', ] as const); export const text = freeze(['#text'] as const); ================================================ FILE: src/utils.ts ================================================ const { entries, setPrototypeOf, isFrozen, getPrototypeOf, getOwnPropertyDescriptor, } = Object; let { freeze, seal, create } = Object; // eslint-disable-line import/no-mutable-exports let { apply, construct } = typeof Reflect !== 'undefined' && Reflect; if (!freeze) { freeze = function (x: T): T { return x; }; } if (!seal) { seal = function (x: T): T { return x; }; } if (!apply) { apply = function ( func: (thisArg: any, ...args: any[]) => T, thisArg: any, ...args: any[] ): T { return func.apply(thisArg, args); }; } if (!construct) { construct = function (Func: new (...args: any[]) => T, ...args: any[]): T { return new Func(...args); }; } const arrayForEach = unapply(Array.prototype.forEach); const arrayIndexOf = unapply(Array.prototype.indexOf); const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf); const arrayPop = unapply(Array.prototype.pop); const arrayPush = unapply(Array.prototype.push); const arraySlice = unapply(Array.prototype.slice); const arraySplice = unapply(Array.prototype.splice); const stringToLowerCase = unapply(String.prototype.toLowerCase); const stringToString = unapply(String.prototype.toString); const stringMatch = unapply(String.prototype.match); const stringReplace = unapply(String.prototype.replace); const stringIndexOf = unapply(String.prototype.indexOf); const stringTrim = unapply(String.prototype.trim); const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty); const regExpTest = unapply(RegExp.prototype.test); const typeErrorCreate = unconstruct(TypeError); /** * Creates a new function that calls the given function with a specified thisArg and arguments. * * @param func - The function to be wrapped and called. * @returns A new function that calls the given function with a specified thisArg and arguments. */ function unapply( func: (thisArg: any, ...args: any[]) => T ): (thisArg: any, ...args: any[]) => T { return (thisArg: any, ...args: any[]): T => { if (thisArg instanceof RegExp) { thisArg.lastIndex = 0; } return apply(func, thisArg, args); }; } /** * Creates a new function that constructs an instance of the given constructor function with the provided arguments. * * @param func - The constructor function to be wrapped and called. * @returns A new function that constructs an instance of the given constructor function with the provided arguments. */ function unconstruct( Func: new (...args: any[]) => T ): (...args: any[]) => T { return (...args: any[]): T => construct(Func, args); } /** * Add properties to a lookup table * * @param set - The set to which elements will be added. * @param array - The array containing elements to be added to the set. * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set. * @returns The modified set with added elements. */ function addToSet( set: Record, array: readonly any[], transformCaseFunc: ReturnType> = stringToLowerCase ): Record { if (setPrototypeOf) { // Make 'in' and truthy checks like Boolean(set.constructor) // independent of any properties defined on Object.prototype. // Prevent prototype setters from intercepting set as a this value. setPrototypeOf(set, null); } let l = array.length; while (l--) { let element = array[l]; if (typeof element === 'string') { const lcElement = transformCaseFunc(element); if (lcElement !== element) { // Config presets (e.g. tags.js, attrs.js) are immutable. if (!isFrozen(array)) { (array as any[])[l] = lcElement; } element = lcElement; } } set[element] = true; } return set; } /** * Clean up an array to harden against CSPP * * @param array - The array to be cleaned. * @returns The cleaned version of the array */ function cleanArray(array: T[]): Array { for (let index = 0; index < array.length; index++) { const isPropertyExist = objectHasOwnProperty(array, index); if (!isPropertyExist) { array[index] = null; } } return array; } /** * Shallow clone an object * * @param object - The object to be cloned. * @returns A new object that copies the original. */ function clone>(object: T): T { const newObject = create(null); for (const [property, value] of entries(object)) { const isPropertyExist = objectHasOwnProperty(object, property); if (isPropertyExist) { if (Array.isArray(value)) { newObject[property] = cleanArray(value); } else if ( value && typeof value === 'object' && value.constructor === Object ) { newObject[property] = clone(value); } else { newObject[property] = value; } } } return newObject; } /** * This method automatically checks if the prop is function or getter and behaves accordingly. * * @param object - The object to look up the getter function in its prototype chain. * @param prop - The property name for which to find the getter function. * @returns The getter function found in the prototype chain or a fallback function. */ function lookupGetter>( object: T, prop: string ): ReturnType> | (() => null) { while (object !== null) { const desc = getOwnPropertyDescriptor(object, prop); if (desc) { if (desc.get) { return unapply(desc.get); } if (typeof desc.value === 'function') { return unapply(desc.value); } } object = getPrototypeOf(object); } function fallbackValue(): null { return null; } return fallbackValue; } export { // Array arrayForEach, arrayIndexOf, arrayLastIndexOf, arrayPop, arrayPush, arraySlice, arraySplice, // Object entries, freeze, getPrototypeOf, getOwnPropertyDescriptor, isFrozen, setPrototypeOf, seal, clone, create, objectHasOwnProperty, // RegExp regExpTest, // String stringIndexOf, stringMatch, stringReplace, stringToLowerCase, stringToString, stringTrim, // Errors typeErrorCreate, // Other lookupGetter, addToSet, // Reflect unapply, unconstruct, }; ================================================ FILE: test/bootstrap-test-suite.js ================================================ const fs = require('fs'); module.exports = function (JSDOM) { class StringWrapper { constructor(s) { this.s = s; } toString() { return this.s; } } function loadDOMPurify( assert, addScriptAttribute, setup, beforeOnLoad, onload ) { const testDone = assert.async(); const { window } = new JSDOM('', { runScripts: 'dangerously', }); require('jquery')(window); if (setup) { setup(window); } const myLibrary = fs.readFileSync('dist/purify.js', { encoding: 'utf-8' }); const scriptEl = window.document.createElement('script'); if (addScriptAttribute) scriptEl.setAttribute('data-tt-policy-suffix', 'suffix'); scriptEl.textContent = myLibrary; window.document.body.appendChild(scriptEl); assert.ok(window.DOMPurify.sanitize); if (beforeOnLoad) { beforeOnLoad(window); } if (onload) { onload(window); } testDone(); } function loadDOMPurifyWithSanityCheck( assert, addScriptAttribute, setup, onload ) { const beforeOnLoadSanityCheck = function (window) { assert.equal( window.DOMPurify.sanitize(''), '' ); }; loadDOMPurify( assert, addScriptAttribute, setup, beforeOnLoadSanityCheck, onload ); } QUnit.test( 'sanity check: works in a non-Trusted Type environment', function (assert) { let policyCreated; loadDOMPurifyWithSanityCheck( assert, false, function setup(window) { delete window.trustedTypes; }, function onload(window) { const output = window.DOMPurify.sanitize(''); assert.ok(typeof output === 'string'); } ); } ); QUnit.test( 'sanity check: works in a Trusted Type environment', function (assert) { let policyCreated; loadDOMPurifyWithSanityCheck( assert, false, function setup(window) { window.trustedTypes = { createPolicy(name, rules) { policyCreated = name; return { createHTML(s) { return new StringWrapper(rules.createHTML(s)); }, }; }, }; }, function onload(window) { assert.equal(policyCreated, 'dompurify'); const output = window.DOMPurify.sanitize('', { RETURN_TRUSTED_TYPE: true, }); assert.equal(output, ''); assert.ok(output instanceof StringWrapper); } ); } ); QUnit.test( 'sanity check: supports configuring the policy suffix via an attribute', function (assert) { let policyCreated; loadDOMPurifyWithSanityCheck( assert, true, function setup(window) { window.trustedTypes = { createPolicy(name, rules) { policyCreated = name; return rules; }, }; }, function onload(window) { assert.equal(policyCreated, 'dompurify#suffix'); } ); } ); QUnit.test('supports TRUSTED_TYPES_POLICY via sanitize()', function (assert) { loadDOMPurify(assert, false, undefined, undefined, function onload(window) { let validationError; try { window.DOMPurify.sanitize('', { TRUSTED_TYPES_POLICY: { createScript(s) { return s; }, }, }); } catch (e) { validationError = e; } assert.equal( validationError.message, 'TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.' ); try { window.DOMPurify.sanitize('', { TRUSTED_TYPES_POLICY: { createHTML(s) { return s; }, }, }); } catch (e) { validationError = e; } assert.equal( validationError.message, 'TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.' ); let suppliedPolicyCallCount = 0; window.DOMPurify.sanitize('', { TRUSTED_TYPES_POLICY: { createHTML(s) { suppliedPolicyCallCount += 1; return new StringWrapper(s); }, createScriptURL(s) { return new StringWrapper(s); }, }, }); assert.equal(suppliedPolicyCallCount, 2); }); }); QUnit.test( 'supports TRUSTED_TYPES_POLICY via setConfig() on a new instance', function (assert) { loadDOMPurify( assert, false, undefined, undefined, function onload(window) { let purify = window.DOMPurify(); assert.notEqual(purify, window.DOMPurify); let suppliedPolicyCallCount = 0; purify.setConfig({ TRUSTED_TYPES_POLICY: { createHTML(s) { suppliedPolicyCallCount += 1; return new StringWrapper(s); }, createScriptURL(s) { return new StringWrapper(s); }, }, }); purify.sanitize(''); assert.equal(suppliedPolicyCallCount, 2); } ); } ); QUnit.test( 'internal TrustedTypes policy is not created when TRUSTED_TYPES_POLICY option is provided', function (assert) { const createdPolicies = []; loadDOMPurify( assert, false, function setup(window) { window.trustedTypes = { createPolicy(name, rules) { createdPolicies.push(name); return { createHTML(s) { return new StringWrapper(rules.createHTML(s)); }, createScriptURL(s) { return new StringWrapper(rules.createScriptURL(s)); }, }; }, }; }, undefined, function onload(window) { assert.equal(createdPolicies.length, 0); const testPolicy = window.trustedTypes.createPolicy('test', { createHTML(s) { return s; }, createScriptURL(s) { return s; }, }); window.DOMPurify.sanitize('', { TRUSTED_TYPES_POLICY: testPolicy, }); assert.equal(createdPolicies.length, 1); assert.equal(createdPolicies[0], 'test'); // Subsequent calls to `sanitize` even without supplying a configuration // should recognize previously set Trusted Types policy. window.DOMPurify.sanitize(''); assert.equal(createdPolicies.length, 1); assert.equal(createdPolicies[0], 'test'); } ); } ); }; ================================================ FILE: test/config/setup.js ================================================ window.alert = function () { window.xssed = true; }; QUnit.assert.contains = function (actual, expected, message) { const result = expected.indexOf(actual) > -1; // Ref: https://api.qunitjs.com/assert/pushResult/ this.pushResult( { result: result, actual: actual, expected: expected, message: message } ); }; ================================================ FILE: test/fixtures/expect.mjs ================================================ export default [ { "title": "Don't remove data URIs from SVG images (see #205)", "payload": "", "expected": "" }, { "title": "Don't remove data URIs from SVG images, with href attribute", "payload": "", "expected": "" }, { "title": "Don't remove ARIA attributes if not prohibited (see #203)", "payload": "
", "expected": "
" }, { "title": "Don't remove binary attributes if considered safe (see #168)", "payload": "", "expected": "" }, { "title": "Avoid over-zealous stripping of SVG filter elements (see #144)", "payload": "", "expected": "" }, { "title": "safe usage of URI-like attribute values (see #135)", "payload": "", "expected": "" }, { "title": "src Attributes for IMG, AUDIO, VIDEO and SOURCE (see #131)", "payload": "
", "expected": "
" }, { "title": "DOM Clobbering against document.createElement() (see #47)", "payload": "", "expected": "" }, { "title": "DOM Clobbering against an empty cookie", "payload": "", "expected": "" }, { "title": "JavaScript URIs using Unicode LS/PS I", "payload": "123I am a dolphin!", "expected": "123I am a dolphin!" }, { "title": "JavaScript URIs using Unicode LS/PS II", "payload": "123I am a dolphin too!", "expected": "123I am a dolphin too!" }, { "title": "JavaScript URIs using Unicode Whitespace", "payload": "123CLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICK", "expected": "123CLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICKCLICK" }, { "title": "Image with data URI src", "payload": "", "expected": "" }, { "title": "Image with data URI src with whitespace", "payload": "", "expected": "" }, { "title": "Image with JavaScript URI src (DoS on Firefox)", "payload": "", "expected": "" }, { "title": "Link with data URI href", "payload": "clickme", "expected": "clickme" }, { "title": "Simple numbers", "payload": "123456", "expected": "123456" }, { "title": "DOM clobbering XSS by @irsdl using attributes", "payload": "
", "expected": ["", "
"] }, { "title": "DOM clobbering: getElementById", "payload": "", "expected": "" }, { "title": "DOM clobbering: location", "payload": "invisible", "expected": "invisible" }, { "title": "onclick, onsubmit, onfocus; DOM clobbering: parentNode", "payload": "
123
", "expected": "
123
" }, { "title": "onsubmit, onfocus; DOM clobbering: nodeName", "payload": "
123
", "expected": "
123
" }, { "title": "onsubmit, onfocus; DOM clobbering: nodeType", "payload": "
123
", "expected": "
123
" }, { "title": "onsubmit, onfocus; DOM clobbering: children", "payload": "
123
", "expected": "
123
" }, { "title": "onsubmit, onfocus; DOM clobbering: attributes", "payload": "
123
", "expected": "
123
" }, { "title": "onsubmit, onfocus; DOM clobbering: removeChild", "payload": "
123
", "expected": "
123
" }, { "title": "onsubmit, onfocus; DOM clobbering: removeAttributeNode", "payload": "
123
", "expected": "
123
" }, { "title": "onsubmit, onfocus; DOM clobbering: setAttribute", "payload": "
123
", "expected": "
123
" }, { "title": ">style<", "payload": "", "expected": "" }, { "title": "HTML paragraph with text", "payload": "

hello

", "expected": "

hello

" }, { "title": "mXSS Variation I", "payload": "<img onerror=\"alert(1);//\" src=x>", "expected": "<img onerror=\"alert(1);//\" src=x>" }, { "title": "mXSS Variation II", "payload": "", "expected": "" }, { "title": "Textarea and comments enabling img element", "payload": "", "expected": "" }, { "title": "Img element inside noscript terminated inside comment", "payload": "", "expected": "" }, { "title": "Img element inside noscript terminated inside attribute", "payload": "", "expected": [ "", "\">", "\">", "" ] }, { "title": "Img element inside shadow DOM template", "payload": "", "expected": "" }, { "title": "Low-range-ASCII obfuscated JavaScript URI", "payload": "@shafigullin", "expected": "@shafigullin" }, { "title": "Img inside style inside broken option element", "payload": "\u0001", "expected": "\u0001" }, { "title": "Iframe inside option element", "payload": "", "expected": "" }, { "title": "Image after style to trick jQuery tag-completion", "payload": "", "expected": "" }, { "title": "MathML example", "payload": "\n \n a,\n a,\n a,\n a,\n a,\n a\n \n", "expected": [ "\n \n a,\n a,\n a,\n a,\n a,\n a\n \n", "\n \n a,\n a,\n a,\n a,\n a,\n a\n \n" ] }, { "title": "DOM clobbering attack using name=body", "payload": "@mmrupp", "expected": "@mmrupp" }, { "title": "Special escapes in protocol handler for XSS in Blink", "payload": "@shafigullin", "expected": "@shafigullin" }, { "title": "DOM clobbering attack using activeElement", "payload": "", "expected": "" }, { "title": "DOM clobbering attack using name=body and injecting SVG + keygen", "payload": ", ", "expected": ", " }, { "title": "Bypass using multiple unknown attributes", "payload": "
@superevr
", "expected": "
@superevr
" }, { "title": "Bypass using event handlers and unknown attributes", "payload": "" }, { "title": "Bypass using DOM bugs when dealing with JS URIs in arbitrary attributes", "payload": "CLICK ME (bypass by @shafigullin)", "expected": "CLICK ME (bypass by @shafigullin)" }, { "title": "Bypass using DOM bugs when dealing with JS URIs in arbitrary attributes (II)", "payload": "", "expected": "


" }, { "title": "Bypass using unknown attributes III", "payload": "
text", "expected": "
text
" }, { "title": "Bypass using unknown attributes IV", "payload": "", "expected": "" }, { "title": "Bypass using unknown attributes V", "payload": "", "expected": "


" }, { "title": "Bypass using JS URI in href", "payload": "CLICK ME (bypass by @shafigullin)", "expected": "CLICK ME (bypass by @shafigullin)" }, { "payload": "
", "expected": "
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
&ADz&AGn&AG0&AEf&ACA&AHM&AHI&AGO&AD0&AGn&ACA&AG8Abg&AGUAcgByAG8AcgA9AGEAbABlAHIAdAAoADEAKQ&ACAAPABi//[\"'`-->]]>]
", "expected": "
&ADz&AGn&AG0&AEf&ACA&AHM&AHI&AGO&AD0&AGn&ACA&AG8Abg&AGUAcgByAG8AcgA9AGEAbABlAHIAdAAoADEAKQ&ACAAPABi//[\"'`-->]]>]
" }, { "payload": "
&alert&A7&(1)&R&UA;&&<&A9&11/script&X&>//[\"'`-->]]>]
", "expected": "
&alert&A7&(1)&R&UA;&&<&A9&11/script&X&>//[\"'`-->]]>]
" }, { "payload": "
0? :postMessage(importScripts('data:;base64,cG9zdE1lc3NhZ2UoJ2FsZXJ0KDEpJyk'))//[\"'`-->]]>]
", "expected": "
0? :postMessage(importScripts('data:;base64,cG9zdE1lc3NhZ2UoJ2FsZXJ0KDEpJyk'))//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
X//[\"'`-->]]>]
\n\n
//[\"'`-->]]>]
", "expected": [ "
X//[\"'`-->]]>]
\n\n
//[\"'`-->]]>]
", "
X//[\"'`-->]]>]
\n\n
//[\"'`-->]]>]
" ] }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "






...



//[\"'`-->]]>]
", "expected": "






...



//[\"'`-->]]>]
" }, { "payload": "
01//[\"'`-->]]>]
", "expected": "
01//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
X//[\"'`-->]]>]
", "expected": "
X//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
\u00BCscript \u00BEalert(19)//\u00BC/script \u00BE//[\"'`-->]]>]
", "expected": "
\u00BCscript \u00BEalert(19)//\u00BC/script \u00BE//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": [ "
//[\"'`-->]]>]
", "
//[\"'`-->]]>]
" ] }, { "payload": "
1`>//[\"'`-->]]>]
", "expected": "
1`>//[\"'`-->]]>]
" }, { "payload": "
;1//[\"'`-->]]>]
", "expected": "
;1//[\"'`-->]]>]
" }, { "payload": "
+ADw-html+AD4APA-body+AD4APA-div+AD4-top secret+ADw-/div+AD4APA-/body+AD4APA-/html+AD4-.toXMLString().match(/.*/m),alert(RegExp.input);//[\"'`-->]]>]
", "expected": "
+ADw-html+AD4APA-body+AD4APA-div+AD4-top secret+ADw-/div+AD4APA-/body+AD4APA-/html+AD4-.toXMLString().match(/.*/m),alert(RegExp.input);//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
1>//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
1>//[\"'`-->]]>]
" }, { "payload": "
]]>]
", "expected": "
]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
XXXXXX//[\"'`-->]]>]
", "expected": "
XXXXXX//[\"'`-->]]>]
" }, { "payload": "
1//[\"'`-->]]>]
", "expected": "
1//[\"'`-->]]>]
" }, { "payload": "
1//[\"'`-->]]>]
", "expected": "
1//[\"'`-->]]>]
" }, { "payload": "
XXX//[\"'`-->]]>]
", "expected": "
XXX//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
//[\"'`-->]]>]
", "expected": [ "
//[\"'`-->]]>]
", "
//[\"'`-->]]>]
" ] }, { "payload": "", "expected": [ "", "", "" ] }, { "payload": "\n><image xlink:href=\"//[\"'`-->]]>]
", "expected": "><image xlink:href=\"//[\"'`-->]]>]" }, { "payload": "
//[\"'`-->]]>]
", "expected": "
//[\"'`-->]]>]
" }, { "payload": "
  • ", "expected": "
  • " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]" }, { "payload": "
    XXX//[\"'`-->]]>]
    ", "expected": "
    XXX//[\"'`-->]]>]
    " }, { "payload": "
    ", "expected": "
    " }, { "payload": "\n\n\n\nHello\n//[\"'`-->]]>]
    ", "expected": "Hello\n//[\"'`-->]]>]" }, { "payload": "
    X//[\"'`-->]]>]
    ", "expected": "
    X//[\"'`-->]]>]
    " }, { "payload": "
    XXX
    //[\"'`-->]]>]
    ", "expected": "
    XXX
    //[\"'`-->]]>]
    " }, { "payload": "
    XXX
    //[\"'`-->]]>]
    ", "expected": "
    XXX
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "//[\"'`-->]]>]
    ", "expected": "//[\"'`-->]]>]" }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    ", "expected": "
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    alert(57)//0//[\"'`-->]]>]
    ", "expected": "
    alert(57)//0//[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    XXX
    //[\"'`-->]]>]
    ", "expected": "
    XXX
    //[\"'`-->]]>]
    " }, { "payload": "
    \n\n\n\n//[\"'`-->]]>]
    ", "expected": "
    \n\n\n\n//[\"'`-->]]>]
    " }, { "payload": "
    // O10.10\u2193, OM10.0\u2193, GC6\u2193, FF\n\n // IE6, O10.10\u2193, OM10.0\u2193\n // IE6, O11.01\u2193, OM10.1\u2193//[\"'`-->]]>]
    ", "expected": "
    // O10.10\u2193, OM10.0\u2193, GC6\u2193, FF\n\n // IE6, O10.10\u2193, OM10.0\u2193\n // IE6, O11.01\u2193, OM10.1\u2193//[\"'`-->]]>]
    " }, { "payload": "
    ]>&x;//[\"'`-->]]>]
    ", "expected": "
    ]>&x;//[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "\n//[\"'`-->]]>]
    \n
    \n]>//[\"'`-->]]>]
    ", "expected": "//[\"'`-->]]>]\n
    \n]>//[\"'`-->]]>]
    " }, { "payload": "
    \n XXX\n//[\"'`-->]]>]
    ", "expected": "
    \n XXX\n//[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    x
    //[\"'`-->]]>]
    ", "expected": "
    x
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    &x;//[\"'`-->]]>]
    ", "expected": "
    &x;//[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    //[\"'`-->]]>]
    \n\n//[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    \n\n//[\"'`-->]]>]
    " }, { "payload": "
    \n\n\n//[\"'`-->]]>]
    ", "expected": "
    \n\n\n//[\"'`-->]]>]
    " }, { "payload": "
    \n
    \n\n\n\n\n
    PRESS ENTER
    //[\"'`-->]]>]
    ", "expected": "
    \n
    \n\n\n\n\n
    PRESS ENTER
    //[\"'`-->]]>]
    " }, { "payload": "
    [A]\n\">\n\">\n\">\n[B]\n\">\n[C]\n\">\n[D]\n<% foo>\">//[\"'`-->]]>]
    ", "expected": "
    [A]\n\">\n\">\n\">\n[B]\n\">\n[C]\n\n[D]\n<% foo>//[\"'`-->]]>]
    " }, { "payload": "
    X
    //[\"'`-->]]>]
    ", "expected": "
    X
    //[\"'`-->]]>]
    " }, { "payload": "
    X
    //[\"'`-->]]>]
    ", "expected": "
    X
    //[\"'`-->]]>]
    " }, { "payload": "
    \nalert(94)\n//[\"'`-->]]>]
    ", "expected": [ "
    \n\n//[\"'`-->]]>]
    ", "
    \nalert(94)\n//[\"'`-->]]>]
    ", "
    \n\n//[\"'`-->]]>]
    " ] }, { "payload": "
    \n\n\n\n//[\"'`-->]]>]
    ", "expected": [ "
    \n\n\n\n//[\"'`-->]]>]
    ", "
    \n\n\n\n\n\n//[\"'`-->]]>]
    ", "
    \n\n\n\n//[\"'`-->]]>]
    " ] }, { "payload": "
    \n//[\"'`-->]]>]
    ", "expected": "
    \n//[\"'`-->]]>]
    " }, { "payload": "
    \n
    //[\"'`-->]]>]
    ", "expected": [ "
    //[\"'`-->]]>]
    " ] }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": [ "
    //[\"'`-->]]>]
    ", "
    //[\"'`-->]]>]
    " ] }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": [ "
    //[\"'`-->]]>]
    ", "
    //[\"'`-->]]>]
    " ] }, { "payload": "
    \n\"`\">\n\n\"`\n\"`//[\"'`-->]]>]
    ", "expected": [ "
    \n\"`><img\n\n\"`><img\n\"`><img//[\"'`-->]]>]
    ", "
    \n\"`\">\n\n\"`\n\"`//[\"'`-->]]>]
    ", "
    \n\"`><img\n\n\"`><img\n\"`><img//[\"'`-->]]>]
    ", "
    \n\n\n\"`\n\"`//[\"'`-->]]>]
    ", "
    \n\n\n\"`><img\n\"`><img//[\"'`-->]]>]
    " ] }, { "payload": "
    \n\n\n//[\"'`-->]]>]
    ", "expected": [ "
    \n\n\n//[\"'`-->]]>]
    ", "
    \n\n\n//[\"'`-->]]>]
    ", "
    \n\n\n//[\"'`-->]]>]
    ", "
    \n\n\n//[\"'`-->]]>]
    ", "
    \n\n\n//[\"'`-->]]>]
    " ] }, { "payload": "
    \n\n//[\"'`-->]]>]
    ", "expected": [ "
    \n\n//[\"'`-->]]>]
    ", "
    \n\n//[\"'`-->]]>]
    ", "
    \n\n//[\"'`-->]]>]
    ", "
    \n\n//[\"'`-->]]>]
    " ] }, { "payload": "
    X
    //[\"'`-->]]>]
    ", "expected": [ "
    X
    //[\"'`-->]]>]
    ", "
    X
    //[\"'`-->]]>]
    " ] }, { "payload": "
    X
    //[\"'`-->]]>]
    XXX
    \n//[\"'`-->]]>]
    ", "expected": [ "
    X
    //[\"'`-->]]>]
    XXX
    \n//[\"'`-->]]>]
    ", "
    X
    //[\"'`-->]]>]
    XXX
    \n//[\"'`-->]]>]
    " ] }, { "payload": "
    XXX//[\"'`-->]]>]
    \n//[\"'`-->]]>]
    ", "expected": "
    XXX//[\"'`-->]]>]
    \n//[\"'`-->]]>]
    " }, { "title": "XML", "payload": "
    x
    \n\n\n\">//[\"'`-->]]>]
    ", "expected": "
    x
    \n\n\n//[\"'`-->]]>]
    " }, { "title": "iframe", "payload": "
    \n \n//[\"'`-->]]>]
    ", "expected": "
    \n \n//[\"'`-->]]>]
    " }, { "title": "Drag & drop", "payload": "
    \n

    Drop me

    \n
    \n//[\"'`-->]]>]
    ", "expected": "
    \n

    Drop me

    \n
    \n//[\"'`-->]]>]
    " }, { "title": "view-source", "payload": "
    ", "expected": "
    " }, { "payload": "//[\"'`-->]]>]
    ", "expected": "//[\"'`-->]]>]" }, { "title": "window.open", "payload": "
    \n\nSpam//[\"'`-->]]>]
    ", "expected": "
    \n\nSpam//[\"'`-->]]>]
    " }, { "payload": "
    \n\n//[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "payload": "
    Some text\nwww.example.org\n\n//[\"'`-->]]>]
    ", "expected": [ "
    Some text\nwww.example.org\n\n//[\"'`-->]]>]
    ", "
    Some text\nwww.example.org\n\n//[\"'`-->]]>]
    " ] }, { "payload": "
    // Safari 5.0, Chrome 9, 10\n // Safari 5.0//[\"'`-->]]>]
    ", "expected": "
    // Safari 5.0, Chrome 9, 10\n // Safari 5.0//[\"'`-->]]>]
    " }, { "payload": "
    ]> //[\"'`-->]]>]
    ", "expected": [ "
    ]> //[\"'`-->]]>]
    ", "
    ]> //[\"'`-->]]>]
    ", "
    ]> //[\"'`-->]]>]
    ", "
    ]> //[\"'`-->]]>]
    ", "
    ]>//[\"'`-->]]>]
    " ] }, { "payload": "
    \n//[\"'`-->]]>]
    ", "expected": "
    \n//[\"'`-->]]>]
    " }, { "payload": "
    \n\nalert(127)\n//[\"'`-->]]>]
    ", "expected": [ "
    \n\nalert(127)\n//[\"'`-->]]>]
    ", "
    \n\n\n//[\"'`-->]]>]
    " ] }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": [ "
    //[\"'`-->]]>]
    ", "
    //[\"'`-->]]>]
    ", "
    " ] }, { "title": "Inline SVG (data-uri)", "payload": "
    \n\n//[\"'`-->]]>]
    ", "expected": [ "
    \n\n//[\"'`-->]]>]
    ", "
    ")\">\n\n//[\"'`-->]]>]
    ", "
    \n\n//[\"'`-->]]>]
    " ] }, { "title": "MathML", "payload": "
    CLICKME\n\n\nCLICKME\n\n\nCLICKMEhttp://http://google.com\n//[\"'`-->]]>]
    ", "expected": [ "
    CLICKME\n\n\n\n\n\n\n//[\"'`-->]]>]
    ", "
    CLICKME\n\n\nCLICKME\n\n\nCLICKMEhttp://http://google.com\n//[\"'`-->]]>]
    ", "
    CLICKME\n//[\"'`-->]]>]
    " ] }, { "payload": "
    \n
    \n\n
    \n\n
    \n\n\n\n\n\n\n\n//[\"'`-->]]>]
    ", "expected": [ "
    \n
    \n\n
    \n\n
    \n\n\n\n\n\n\n\n//[\"'`-->]]>]
    ", "
    \n
    \n\n
    \n\n
    \n\n\n\n\n\n\n\n//[\"'`-->]]>]
    " ] }, { "payload": "
    //[\"'`-->]]>]
    ", "expected": "
    //[\"'`-->]]>]
    " }, { "title": "XMP", "payload": "
    \n<%\n\n%></xmp><img src=xx onerror=alert(134)//\n\n %>/\nalert(2)\n\n\nXXX\n\n-->{}\n*{color:red}//[\"'`-->]]>]
    ", "expected": [ "
    \n\"%\n\n %>/\nalert(2)\n\n\nXXX\n\n-->{}\n*{color:red}//[\"'`-->]]>]
    ", "
    \n\"%></xmp><img\n\n %>/\nalert(2)\n\n\nXXX\n\n->{}\n*{color:red}//[\"'`-->]]>]
    ", "
    \n\"%\n\n %>/\nalert(2)\n\n\nXXX\n\n-->{}\n*{color:red}//[\"'`-->]]>]
    ", "
    \n\"%></xmp><img\n\n %>/\nalert(2)\n\n\nXXX\n\n-->{}\n*{color:red}//[\"'`-->]]>]
    ", "
    \n\n\n %>/\nalert(2)\n\n\nXXX\n\n-->{}\n*{color:red}//[\"'`-->]]>]
    " ] }, { "title": "SVG", "payload": "
    \n\n\n//[\"'`-->]]>]
    ", "expected": [ "
    \n\n\n//[\"'`-->]]>]
    ", "
    \n\n\n//[\"'`-->]]>]
    ", "
    \n\n\n//[\"'`-->]]>]
    ", "
    \n\n\n//[\"'`-->]]>]
    " ] }, { "payload": "
    \n\n\n\n\n
    //[\"'`-->]]>]
    ", "expected": [ "
    \n\n\n\n\n
    //[\"'`-->]]>]
    ", "
    \n\n\n\n\n
    //[\"'`-->]]>]
    " ] }, { "title": "SVG", "payload": "
    \n\n\n\n//[\"'`-->]]>]
    ", "expected": "
    \n\n\n\n//[\"'`-->]]>]
    " }, { "title": "DOM clobbering: submit", "payload": "123", "expected": "123" }, { "title": "DOM clobbering: acceptCharset", "payload": "123", "expected": "123" }, { "title": "DOM clobbering: hasChildNodes", "payload": "
    ", "expected": "
    " },{ "title": "Testing support for sizes and srcset", "payload": "", "expected": [ "", "" ] }, { "title": "Testing support for inert", "payload": "
    ", "expected": "
    " }, { "title": "Tests against mXSS behavior with SVG in Chrome 77 and alike 1/2", "payload": "

    ", "expected": [ "", "

    ", "", "

    ", "" ] }, { "title": "Tests against mXSS behavior with SVG in Chrome 77 and alike 2/2", "payload": "

    \">", "expected": [ "", "

    <a id=\"\">", "\">
    ", "\">", "\">
    ", "" ] }, { "title": "Tests against mXSS behavior with MathML in Chrome 77 and alike", "payload": "