Showing preview only (1,020K chars total). Download the full file or copy to clipboard to get everything.
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
<!-- Explain this change, e.g. "this pull request [implements, fixes, changes]...". -->
## Background & Context
<!-- Briefly outline why this PR was needed, a minimal context, culminating in your implementation. -->
## Tasks
<!-- Add tasks to give a quick overview for QA and reviewers -->
- xxxx
- xxxx
- xxxx
## Dependencies
<!-- If there are any dependencies on PRs or API work then list them here. -->
- [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
[](http://badge.fury.io/js/dompurify)  [](https://www.npmjs.com/package/dompurify)  [](https://github.com/cure53/DOMPurify/network/dependents) [](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
<script type="text/javascript" src="dist/purify.js"></script>
```
### Using the minified and tested production version (source-map available)
```html
<script type="text/javascript" src="dist/purify.min.js"></script>
```
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('<b>hello there</b>');
```
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('<b>hello there</b>');
```
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('<b>hello there</b>');
```
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('<s>hello</s>');
```
## 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('<img src=x onerror=alert(1)//>'); // becomes <img src="x">
DOMPurify.sanitize('<svg><g/onload=alert(2)//<p>'); // becomes <svg><g></g></svg>
DOMPurify.sanitize('<p>abc<iframe//src=jAva	script:alert(3)>def</p>'); // becomes <p>abc</p>
DOMPurify.sanitize('<math><mi//xlink:href="data:x,<script>alert(4)</script>">'); // becomes <math><mi></mi></math>
DOMPurify.sanitize('<TABLE><tr><td>HELLO</tr></TABL>'); // becomes <table><tbody><tr><td>HELLO</td></tr></tbody></table>
DOMPurify.sanitize('<UL><li><A HREF=//google.com>click</UL>'); // becomes <ul><li><a href="//google.com">click</a></li></ul>
```
## What is supported?
DOMPurify currently supports HTML5, SVG and MathML. DOMPurify per default allows CSS, HTML custom data attributes. DOMPurify also supports the Shadow DOM - and sanitizes DOM templates recursively. DOMPurify also allows you to sanitize HTML for being used with the jQuery `$()` and `elm.html()` API without any known problems.
## What about legacy browsers like Internet Explorer?
DOMPurify does nothing at all. It simply returns exactly the string that you fed it. DOMPurify exposes a property called `isSupported`, which tells you whether it will be able to do its job, so you can come up with your own backup plan.
## What about DOMPurify and Trusted Types?
In version 1.0.9, support for [Trusted Types API](https://github.com/w3c/webappsec-trusted-types) was added to DOMPurify.
In version 2.0.0, a config flag was added to control DOMPurify's behavior regarding this.
When `DOMPurify.sanitize` is used in an environment where the Trusted Types API is available and `RETURN_TRUSTED_TYPE` is set to `true`, it tries to return a `TrustedHTML` value instead of a string (the behavior for `RETURN_DOM` and `RETURN_DOM_FRAGMENT` config options does not change).
Note that in order to create a policy in `trustedTypes` using DOMPurify, `RETURN_TRUSTED_TYPE: false` is required, as `createHTML` expects a normal string, not `TrustedHTML`. The example below shows this.
```js
window.trustedTypes!.createPolicy('default', {
createHTML: (to_escape) =>
DOMPurify.sanitize(to_escape, { RETURN_TRUSTED_TYPE: false }),
});
```
## Can I configure DOMPurify?
Yes. The included default configuration values are pretty good already - but you can of course override them. Check out the [`/demos`](https://github.com/cure53/DOMPurify/tree/main/demos) folder to see a bunch of examples on how you can [customize DOMPurify](https://github.com/cure53/DOMPurify/tree/main/demos#what-is-this).
### General settings
```js
// 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.
const clean = DOMPurify.sanitize(dirty, {SAFE_FOR_TEMPLATES: true});
// 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.
const clean = DOMPurify.sanitize(dirty, {SAFE_FOR_XML: false});
```
### Control our allow-lists and block-lists
```js
// allow only <b> elements, very strict
const clean = DOMPurify.sanitize(dirty, {ALLOWED_TAGS: ['b']});
// allow only <b> and <q> with style attributes
const clean = DOMPurify.sanitize(dirty, {ALLOWED_TAGS: ['b', 'q'], ALLOWED_ATTR: ['style']});
// allow all safe HTML elements but neither SVG nor MathML
// note that the USE_PROFILES setting will override the ALLOWED_TAGS setting
// so don't use them together
const clean = DOMPurify.sanitize(dirty, {USE_PROFILES: {html: true}});
// allow all safe SVG elements and SVG Filters, no HTML or MathML
const clean = DOMPurify.sanitize(dirty, {USE_PROFILES: {svg: true, svgFilters: true}});
// allow all safe MathML elements and SVG, but no SVG Filters
const clean = DOMPurify.sanitize(dirty, {USE_PROFILES: {mathMl: true, svg: true}});
// change the default namespace from HTML to something different
const clean = DOMPurify.sanitize(dirty, {NAMESPACE: 'http://www.w3.org/2000/svg'});
// leave all safe HTML as it is and add <style> elements to block-list
const clean = DOMPurify.sanitize(dirty, {FORBID_TAGS: ['style']});
// leave all safe HTML as it is and add style attributes to block-list
const clean = DOMPurify.sanitize(dirty, {FORBID_ATTR: ['style']});
// extend the existing array of allowed tags and add <my-tag> to allow-list
const clean = DOMPurify.sanitize(dirty, {ADD_TAGS: ['my-tag']});
// extend the existing array of allowed attributes and add my-attr to allow-list
const clean = DOMPurify.sanitize(dirty, {ADD_ATTR: ['my-attr']});
// use functions to control which additional tags and attributes are allowed
const allowlist = {
'one': ['attribute-one'],
'two': ['attribute-two']
};
const clean = DOMPurify.sanitize(
'<one attribute-one="1" attribute-two="2"></one><two attribute-one="1" attribute-two="2"></two>',
{
ADD_TAGS: (tagName) => {
return Object.keys(allowlist).includes(tagName);
},
ADD_ATTR: (attributeName, tagName) => {
return allowlist[tagName]?.includes(attributeName) || false;
}
}
); // <one attribute-one="1"></one><two attribute-two="2"></two>
// prohibit ARIA attributes, leave other safe HTML as is (default is true)
const clean = DOMPurify.sanitize(dirty, {ALLOW_ARIA_ATTR: false});
// prohibit HTML5 data attributes, leave other safe HTML as is (default is true)
const clean = DOMPurify.sanitize(dirty, {ALLOW_DATA_ATTR: false});
```
### Control behavior relating to Custom Elements
```js
// DOMPurify allows to define rules for Custom Elements. When using the CUSTOM_ELEMENT_HANDLING
// literal, it is possible to define exactly what elements you wish to allow (by default, none are allowed).
//
// The same goes for their attributes. By default, the built-in or configured allow.list is used.
//
// You can use a RegExp literal to specify what is allowed or a predicate, examples for both can be seen below.
// When using a predicate function for attributeNameCheck, it can optionally receive the tagName as a second parameter
// for more granular control over which attributes are allowed for specific elements.
// The default values are very restrictive to prevent accidental XSS bypasses. Handle with great care!
const clean = DOMPurify.sanitize(
'<foo-bar baz="foobar" forbidden="true"></foo-bar><div is="foo-baz"></div>',
{
CUSTOM_ELEMENT_HANDLING: {
tagNameCheck: null, // no custom elements are allowed
attributeNameCheck: null, // default / standard attribute allow-list is used
allowCustomizedBuiltInElements: false, // no customized built-ins allowed
},
}
); // <div is=""></div>
const clean = DOMPurify.sanitize(
'<foo-bar baz="foobar" forbidden="true"></foo-bar><div is="foo-baz"></div>',
{
CUSTOM_ELEMENT_HANDLING: {
tagNameCheck: /^foo-/, // allow all tags starting with "foo-"
attributeNameCheck: /baz/, // allow all attributes containing "baz"
allowCustomizedBuiltInElements: true, // customized built-ins are allowed
},
}
); // <foo-bar baz="foobar"></foo-bar><div is="foo-baz"></div>
const clean = DOMPurify.sanitize(
'<foo-bar baz="foobar" forbidden="true"></foo-bar><div is="foo-baz"></div>',
{
CUSTOM_ELEMENT_HANDLING: {
tagNameCheck: (tagName) => tagName.match(/^foo-/), // allow all tags starting with "foo-"
attributeNameCheck: (attr) => attr.match(/baz/), // allow all containing "baz"
allowCustomizedBuiltInElements: true, // allow customized built-ins
},
}
); // <foo-bar baz="foobar"></foo-bar><div is="foo-baz"></div>
// Example with attributeNameCheck receiving tagName as a second parameter
const clean = DOMPurify.sanitize(
'<element-one attribute-one="1" attribute-two="2"></element-one><element-two attribute-one="1" attribute-two="2"></element-two>',
{
CUSTOM_ELEMENT_HANDLING: {
tagNameCheck: (tagName) => tagName.match(/^element-(one|two)$/),
attributeNameCheck: (attr, tagName) => {
if (tagName === 'element-one') {
return ['attribute-one'].includes(attr);
} else if (tagName === 'element-two') {
return ['attribute-two'].includes(attr);
} else {
return false;
}
},
allowCustomizedBuiltInElements: false,
},
}
); // <element-one attribute-one="1"></element-one><element-two attribute-two="2"></element-two>
```
### Control behavior relating to URI values
```js
// extend the existing array of elements that can use Data URIs
const clean = DOMPurify.sanitize(dirty, {ADD_DATA_URI_TAGS: ['a', 'area']});
// extend the existing array of elements that are safe for URI-like values (be careful, XSS risk)
const clean = DOMPurify.sanitize(dirty, {ADD_URI_SAFE_ATTR: ['my-attr']});
```
### Control permitted attribute values
```js
// 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.
const clean = DOMPurify.sanitize(dirty, {ALLOW_UNKNOWN_PROTOCOLS: true});
// allow specific protocols handlers in URL attributes via regex (default is false, be careful, XSS risk)
// by default only (protocol-)relative URLs, http, https, ftp, ftps, tel, mailto, callto, sms, cid, xmpp and matrix are allowed.
// Default RegExp: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i;
const clean = DOMPurify.sanitize(dirty, {ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i});
```
### Influence the return-type
```js
// return a DOM HTMLBodyElement instead of an HTML string (default is false)
const clean = DOMPurify.sanitize(dirty, {RETURN_DOM: true});
// return a DOM DocumentFragment instead of an HTML string (default is false)
const clean = DOMPurify.sanitize(dirty, {RETURN_DOM_FRAGMENT: true});
// use the RETURN_TRUSTED_TYPE flag to turn on Trusted Types support if available
const clean = DOMPurify.sanitize(dirty, {RETURN_TRUSTED_TYPE: true}); // will return a TrustedHTML object instead of a string if possible
// use a provided Trusted Types policy
const clean = DOMPurify.sanitize(dirty, {
// supplied policy must define createHTML and createScriptURL
TRUSTED_TYPES_POLICY: trustedTypes.createPolicy({
createHTML(s) { return s},
createScriptURL(s) { return s},
})
});
```
### Influence how we sanitize
```js
// return entire document including <html> tags (default is false)
const clean = DOMPurify.sanitize(dirty, {WHOLE_DOCUMENT: true});
// disable DOM Clobbering protection on output (default is true, handle with care, minor XSS risks here)
const clean = DOMPurify.sanitize(dirty, {SANITIZE_DOM: false});
// 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-`
const clean = DOMPurify.sanitize(dirty, {SANITIZE_NAMED_PROPS: true});
// keep an element's content when the element is removed (default is true)
const clean = DOMPurify.sanitize(dirty, {KEEP_CONTENT: false});
// glue elements like style, script or others to document.body and prevent unintuitive browser behavior in several edge-cases (default is false)
const clean = DOMPurify.sanitize(dirty, {FORCE_BODY: true});
// remove all <a> elements under <p> elements that are removed
const clean = DOMPurify.sanitize(dirty, {FORBID_CONTENTS: ['a'], FORBID_TAGS: ['p']});
// extend the default FORBID_CONTENTS list to also remove <a> elements under <p> elements
const clean = DOMPurify.sanitize(dirty, {ADD_FORBID_CONTENTS: ['a'], FORBID_TAGS: ['p']});
// change the parser type so sanitized data is treated as XML and not as HTML, which is the default
const clean = DOMPurify.sanitize(dirty, {PARSER_MEDIA_TYPE: 'application/xhtml+xml'});
```
### Influence where we sanitize
```js
// use the IN_PLACE mode to sanitize a node "in place", which is much faster depending on how you use DOMPurify
const dirty = document.createElement('a');
dirty.setAttribute('href', 'javascript:alert(1)');
const clean = DOMPurify.sanitize(dirty, {IN_PLACE: true}); // see https://github.com/cure53/DOMPurify/issues/288 for more info
```
There is even [more examples here](https://github.com/cure53/DOMPurify/tree/main/demos#what-is-this), showing how you can run, customize and configure DOMPurify to fit your needs.
## Persistent Configuration
Instead of repeatedly passing the same configuration to `DOMPurify.sanitize`, you can use the `DOMPurify.setConfig` method. Your configuration will persist until your next call to `DOMPurify.setConfig`, or until you invoke `DOMPurify.clearConfig` to reset it. Remember that there is only one active configuration, which means once it is set, all extra configuration parameters passed to `DOMPurify.sanitize` are ignored.
## Hooks
DOMPurify allows you to augment its functionality by attaching one or more functions with the `DOMPurify.addHook` method to one of the following hooks:
- `beforeSanitizeElements`
- `uponSanitizeElement` (No 's' - called for every element)
- `afterSanitizeElements`
- `beforeSanitizeAttributes`
- `uponSanitizeAttribute`
- `afterSanitizeAttributes`
- `beforeSanitizeShadowDOM`
- `uponSanitizeShadowNode`
- `afterSanitizeShadowDOM`
It passes the currently processed DOM node, when needed a literal with verified node and attribute data and the DOMPurify configuration to the callback. Check out the [MentalJS hook demo](https://github.com/cure53/DOMPurify/blob/main/demos/hooks-mentaljs-demo.html) to see how the API can be used nicely.
_Example_:
```js
DOMPurify.addHook(
'uponSanitizeAttribute',
function (currentNode, hookEvent, config) {
// Do something with the current node
// You can also mutate hookEvent for current node (i.e. set hookEvent.forceKeepAttr = true)
// For other than 'uponSanitizeAttribute' hook types hookEvent equals to null
}
);
```
## Removed Configuration
| Option | Since | Note |
|-----------------|-------|--------------------------|
| SAFE_FOR_JQUERY | 2.1.0 | No replacement required. |
## Continuous Integration
We are currently using Github Actions in combination with BrowserStack. This gives us the possibility to confirm for each and every commit that all is going according to plan in all supported browsers. Check out the build logs here: https://github.com/cure53/DOMPurify/actions
You can further run local tests by executing `npm run test`.
All relevant commits will be signed with the key `0x24BB6BF4` for additional security (since 8th of April 2016).
### Development and contributing
#### Installation (`npm i`)
We support `npm` officially. GitHub Actions workflow is configured to install dependencies using `npm`. When using deprecated version of `npm` we can not fully ensure the versions of installed dependencies which might lead to unanticipated problems.
#### Scripts
We use ESLint as a pre-commit hook to ensure code consistency. Moreover, to ease formatting we use [prettier](https://github.com/prettier/prettier) while building the `/dist` assets happens through `rollup`.
These are our npm scripts:
- `npm run dev` to start building while watching sources for changes
- `npm run test` to run our test suite via jsdom and karma
- `test:jsdom` to only run tests through jsdom
- `test:karma` to only run tests through karma
- `npm run lint` to lint the sources using ESLint (via xo)
- `npm run format` to format our sources using prettier to ease to pass ESLint
- `npm run build` to build our distribution assets minified and unminified as a UMD module
- `npm run build:umd` to only build an unminified UMD module
- `npm run build:umd:min` to only build a minified UMD module
Note: all run scripts triggered via `npm run <script>`.
There are more npm scripts but they are mainly to integrate with CI or are meant to be "private" for instance to amend build distribution files with every commit.
## Security Mailing List
We maintain a mailing list that notifies whenever a security-critical release of DOMPurify was published. This means, if someone found a bypass and we fixed it with a release (which always happens when a bypass was found) a mail will go out to that list. This usually happens within minutes or few hours after learning about a bypass. The list can be subscribed to here:
[https://lists.ruhr-uni-bochum.de/mailman/listinfo/dompurify-security](https://lists.ruhr-uni-bochum.de/mailman/listinfo/dompurify-security)
Feature releases will not be announced to this list.
## Who contributed?
Many people helped and help DOMPurify become what it is and need to be acknowledged here!
[Cybozu 💛💸](https://github.com/cybozu), [hata6502 💸](https://github.com/hata6502), [intra-mart-dh 💸](https://github.com/intra-mart-dh), [nelstrom ❤️](https://github.com/nelstrom), [hash_kitten ❤️](https://twitter.com/hash_kitten), [kevin_mizu ❤️](https://twitter.com/kevin_mizu), [icesfont ❤️](https://github.com/icesfont), [reduckted ❤️](https://github.com/reduckted), [dcramer 💸](https://github.com/dcramer), [JGraph 💸](https://github.com/jgraph), [baekilda 💸](https://github.com/baekilda), [Healthchecks 💸](https://github.com/healthchecks), [Sentry 💸](https://github.com/getsentry), [jarrodldavis 💸](https://github.com/jarrodldavis), [CynegeticIO](https://github.com/CynegeticIO), [ssi02014 ❤️](https://github.com/ssi02014), [GrantGryczan](https://github.com/GrantGryczan), [Lowdefy](https://twitter.com/lowdefy), [granlem](https://twitter.com/MaximeVeit), [oreoshake](https://github.com/oreoshake), [tdeekens ❤️](https://github.com/tdeekens), [peernohell ❤️](https://github.com/peernohell), [is2ei](https://github.com/is2ei), [SoheilKhodayari](https://github.com/SoheilKhodayari), [franktopel](https://github.com/franktopel), [NateScarlet](https://github.com/NateScarlet), [neilj](https://github.com/neilj), [fhemberger](https://github.com/fhemberger), [Joris-van-der-Wel](https://github.com/Joris-van-der-Wel), [ydaniv](https://github.com/ydaniv), [terjanq](https://twitter.com/terjanq), [filedescriptor](https://github.com/filedescriptor), [ConradIrwin](https://github.com/ConradIrwin), [gibson042](https://github.com/gibson042), [choumx](https://github.com/choumx), [0xSobky](https://github.com/0xSobky), [styfle](https://github.com/styfle), [koto](https://github.com/koto), [tlau88](https://github.com/tlau88), [strugee](https://github.com/strugee), [oparoz](https://github.com/oparoz), [mathiasbynens](https://github.com/mathiasbynens), [edg2s](https://github.com/edg2s), [dnkolegov](https://github.com/dnkolegov), [dhardtke](https://github.com/dhardtke), [wirehead](https://github.com/wirehead), [thorn0](https://github.com/thorn0), [styu](https://github.com/styu), [mozfreddyb](https://github.com/mozfreddyb), [mikesamuel](https://github.com/mikesamuel), [jorangreef](https://github.com/jorangreef), [jimmyhchan](https://github.com/jimmyhchan), [jameydeorio](https://github.com/jameydeorio), [jameskraus](https://github.com/jameskraus), [hyderali](https://github.com/hyderali), [hansottowirtz](https://github.com/hansottowirtz), [hackvertor](https://github.com/hackvertor), [freddyb](https://github.com/freddyb), [flavorjones](https://github.com/flavorjones), [djfarrelly](https://github.com/djfarrelly), [devd](https://github.com/devd), [camerondunford](https://github.com/camerondunford), [buu700](https://github.com/buu700), [buildog](https://github.com/buildog), [alabiaga](https://github.com/alabiaga), [Vector919](https://github.com/Vector919), [Robbert](https://github.com/Robbert), [GreLI](https://github.com/GreLI), [FuzzySockets](https://github.com/FuzzySockets), [ArtemBernatskyy](https://github.com/ArtemBernatskyy), [@garethheyes](https://twitter.com/garethheyes), [@shafigullin](https://twitter.com/shafigullin), [@mmrupp](https://twitter.com/mmrupp), [@irsdl](https://twitter.com/irsdl),[ShikariSenpai](https://github.com/ShikariSenpai), [ansjdnakjdnajkd](https://github.com/ansjdnakjdnajkd), [@asutherland](https://twitter.com/asutherland), [@mathias](https://twitter.com/mathias), [@cgvwzq](https://twitter.com/cgvwzq), [@robbertatwork](https://twitter.com/robbertatwork), [@giutro](https://twitter.com/giutro), [@CmdEngineer\_](https://twitter.com/CmdEngineer_), [@avr4mit](https://twitter.com/avr4mit), [davecardwell](https://github.com/davecardwell) and especially [@securitymb ❤️](https://twitter.com/securitymb) & [@masatokinugawa ❤️](https://twitter.com/masatokinugawa)
## Testing powered by
<a target="_blank" href="https://www.browserstack.com/"><img width="200" src="https://github.com/cure53/DOMPurify/assets/6709482/f70be7eb-8fc4-41ea-9653-9d359235328f"></a><br>
And last but not least, thanks to [BrowserStack Open-Source Program](https://www.browserstack.com/open-source) for supporting this project with their services for free and delivering excellent, dedicated and very professional support on top of that.
================================================
FILE: SECURITY.md
================================================
## Supported Versions
Always the latest release.
## Reporting a Vulnerability
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/).
================================================
FILE: bower.json
================================================
{
"name": "dompurify",
"version": "3.3.3",
"homepage": "https://github.com/cure53/DOMPurify",
"author": "Cure53 <info@cure53.de>",
"description": "A DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG",
"main": "dist/purify.min.js",
"keywords": [
"dom",
"xss",
"cross site scripting",
"html",
"svg",
"mathml",
"sanitizer",
"filter",
"sanitize",
"security",
"secure"
],
"license": [
"MPL-2.0",
"Apache-2.0"
],
"ignore": [
"**/.*",
"demos",
"scripts",
"test",
"website"
]
}
================================================
FILE: demos/README.md
================================================
## What is this?
This is a collection of demos of how to use DOMPurify. When run without any additional configuration parameters, DOMPurify will reliably protect against XSS and DOM Clobbering attacks. But there is a lot of more things this library can do. For example proxy all HTTP resources, enhance accessibility, prevent links to open in the same window, allow and sand-box JavaScript and more.
This collection of demos shows to same code for several different ways you can use DOMPurify. Please feel free to suggest additional demos if needed. All demos we have collected so far will be shown and explained below.
### Basic Demo [Link](basic-demo.html)
This is the most basic of all demos. It shows how you user DOMPurify and that's it. No configuration, no hooks, no extras. Just DOMPurify running with default settings.
This is the relevant code:
```javascript
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
```
### Config Demo [Link](config-demo.html)
This demo shows how to use the configuration object the right way. In this demo, we only permit `<p>` elements and we want to preserve their text, but not the content of nested elements inside the `<p>`.
This is the relevant code:
```javascript
// Specify a configuration directive, only <P> elements allowed
// Note: We want to also keep <p>'s text content, so we add #text too
const config = { ALLOWED_TAGS: ['p', '#text'], KEEP_CONTENT: false };
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty, config);
```
### Advanced Config Demo [Link](advanced-config-demo.html)
This demo shows, how we can use the configuration object to instruct DOMPurify to be more specific with what is to be permitted and what is not. We want to permit `<p>` elements and the fictional `<ying>` and `<yang>` tag. We also want to allow the `kitty-litter` attribute because why not - and make sure that a `document`-object is returned after sanitation - and not a plain string.
This is the relevant code:
```javascript
// Specify a configuration directive
const config = {
ALLOWED_TAGS: ['p', '#text'], // only <P> 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);
```
### Hooks Demo [Link](hooks-demo.html)
DOMPurify allows you to use hooks. Hooks are basically scripts that can hook into certain parts of the DOMPurify code flow and do stuff. Stuff that you like to be done. By using hooks, you can literally make DOMPurify do whatever. To show you, how powerful and easy to use hooks are, we created some demos for you. Like this one, that essentially renders all tag content to be in capitals.
This is the relevant code:
```javascript
// Add a hook to convert all text to capitals
DOMPurify.addHook('beforeSanitizeAttributes', function (node) {
// Set text node content to uppercase
if (node.nodeName && node.nodeName === '#text') {
node.textContent = node.textContent.toUpperCase();
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
```
### Add hooks and remove hooks [Link](hooks-removal-demo.html)
A DOMPurify hook can also be removed in case you first need it and then you want to get rid of it right afterwards. This demo shows how you do that with ease and elegance.
This is the relevant code:
```javascript
// Add a hook to convert all text to capitals
DOMPurify.addHook('beforeSanitizeAttributes', function (node) {
// Set text node content to uppercase
if (node.nodeName && node.nodeName === '#text') {
node.textContent = node.textContent.toUpperCase();
}
});
// Clean HTML string and write into our DIV
let clean = DOMPurify.sanitize(dirty);
// now let's remove the hook again
console.log(DOMPurify.removeHook('beforeSanitizeAttributes'));
// Clean HTML string and write into our DIV
let clean = DOMPurify.sanitize(dirty);
```
### Hook to open all links in a new window [Link](hooks-target-blank-demo.html)
This hook is an important one and used quite commonly. It is made to assure that all elements that can function as a link will open the linked page in a new tab or window. This is often of great importance in web mailers and other tools, where a click on a link is not supposed to navigate the original page but rather open another window or tab.
This is the relevant code:
```javascript
// Add a hook to make all links open a new window
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
// set all elements owning target to target=_blank
if ('target' in node) {
node.setAttribute('target', '_blank');
}
// set non-HTML/MathML links to xlink:show=new
if (
!node.hasAttribute('target') &&
(node.hasAttribute('xlink:href') || node.hasAttribute('href'))
) {
node.setAttribute('xlink:show', 'new');
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
```
### Hook to white-list safe URI Schemes [Link](hooks-scheme-allowlist.html)
Depending on where you show your sanitized HTML, different URI schemes might cause trouble. And in most situations, you only want to allow HTTP and HTTPS - but not any of those fancy URI schemes supported on mobile devices or even on the desktop with Windows 10. This hook demo shows how to easily make sure only HTTP, HTTPS and FTP URIs are permitted while all others are eliminated for good.
Note that you might want to be more thorough, if not only links but also backgrounds and other attributes should be covered. We have an example later on to [cover all these too](hooks-proxy-demo.html).
This is the relevant code:
```javascript
// allowed URI schemes
const allowlist = ['http', 'https', 'ftp'];
// build fitting regex
const regex = RegExp('^(' + allowlist.join('|') + '):', 'gim');
// Add a hook to enforce URI scheme allow-list
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
// build an anchor to map URLs to
const anchor = document.createElement('a');
// check all href attributes for validity
if (node.hasAttribute('href')) {
anchor.href = node.getAttribute('href');
if (anchor.protocol && !anchor.protocol.match(regex)) {
node.removeAttribute('href');
}
}
// check all action attributes for validity
if (node.hasAttribute('action')) {
anchor.href = node.getAttribute('action');
if (anchor.protocol && !anchor.protocol.match(regex)) {
node.removeAttribute('action');
}
}
// check all xlink:href attributes for validity
if (node.hasAttribute('xlink:href')) {
anchor.href = node.getAttribute('xlink:href');
if (anchor.protocol && !anchor.protocol.match(regex)) {
node.removeAttribute('xlink:href');
}
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
```
### Hook to allow and sand-box all JavaScript [Link](hooks-mentaljs-demo.html)
Okay, now this is real witch-craft! Imagine you want users to submit JavaScript but it should be sand-boxed. With a hook, you can actually do that. What we are doing here is permitting all JavaScript and event handlers, but take their contents and sand-box it using Gareth Heyes' amazing [MentalJS](https://github.com/hackvertor/MentalJS) library. The hook shows how do to this safely.
Be careful though, this is playing with fire. If you want to use this in production, better give us a quick ping to see if all is really working as desired.
This is the relevant code:
```javascript
// allow script elements
const config = {
ADD_TAGS: ['script'],
ADD_ATTR: ['onclick', 'onmouseover', 'onload', 'onunload'],
};
// Add a hook to sanitize all script content with MentalJS
DOMPurify.addHook('uponSanitizeElement', function (node, data) {
if (data.tagName === 'script') {
let script = node.textContent;
if (
!script ||
'src' in node.attributes ||
'href' in node.attributes ||
'xlink:href' in node.attributes
) {
return node.parentNode.removeChild(node);
}
try {
let mental = MentalJS().parse({
options: {
eval: false,
dom: true,
},
code: script,
});
return (node.textContent = mental);
} catch (e) {
return node.parentNode.removeChild(node);
}
}
});
// Add a hook to sanitize all white-listed events with MentalJS
DOMPurify.addHook('uponSanitizeAttribute', function (node, data) {
if (data.attrName.match(/^on\w+/)) {
let script = data.attrValue;
try {
return (data.attrValue = MentalJS().parse({
options: {
eval: false,
dom: true,
},
code: script,
}));
} catch (e) {
return (data.attrValue = '');
}
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty, config);
```
### Hook to proxy all links [Link](hooks-link-proxy-demo.html)
DOMPurify itself permits links to all resources that don't cause XSS. That includes pretty much all URI schemes and of course HTTP and HTTPS links. Yet, often, preventing XSS is not everything you want to do. And a common use case for a sanitizer is to also proxy all existing links on a website to make sure a de-referrer is used or the website owner has more control over what links are pointing where - to avoid referrer leaks, attacks using window.opener and alike. This hook shows, how all out-bound links can easily be proxied for maximum safety.
This is the relevant code:
```javascript
// Add a hook to make all links point to a proxy
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
// proxy form actions
if ('action' in node) {
node.setAttribute(
'action',
proxy + encodeURIComponent(node.getAttribute('action'))
);
}
// proxy regular HTML links
if (node.hasAttribute('href')) {
node.setAttribute(
'href',
proxy + encodeURIComponent(node.getAttribute('href'))
);
}
// proxy SVG/MathML links
if (node.hasAttribute('xlink:href')) {
node.setAttribute(
'xlink:href',
proxy + encodeURIComponent(node.getAttribute('xlink:href'))
);
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
```
### Hook to proxy all HTTP leaks including CSS [Link](hooks-proxy-demo.html)
Now this is a hook you don't talk about on your first date. This monster has the purpose of proxying **all** known [HTTP leaks](https://github.com/cure53/HTTPLeaks) including the ones hidden in CSS. It proxies HTML, CSS rules, in-line styles, `@media` rules, `@font-face` rules and `@keyframes`. It further eliminates `@charset` and `@import` as they both help carrying out XSS attacks. This hook is supposed to be a comprehensive demo on how to cover each and every HTTP leak. That's why the amount of code is a bit higher than usual.
When ever you want to reliably filter HTML and CSS using DOMPurify, this is the way to go. How to try the demo? Run the HTML file linked above in your browser and have a look at the network tab of your favorite debugger. You will see that all external resources are proxied. If not then you found a bug.
This is the relevant code:
```javascript
// Specify proxy URL
const proxy = 'https://my.proxy/?url=';
// What do we allow? Not much for now. But it's tight.
const config = {
FORBID_TAGS: ['svg'],
WHOLE_DOCUMENT: true,
};
// Specify attributes to proxy
const attributes = ['action', 'background', 'href', 'poster', 'src', 'srcset']
// specify the regex to detect external content
const regex = /(url\("?)(?!data:)/gim;
/**
* Take CSS property-value pairs and proxy URLs in values,
* then add the styles to an array of property-value pairs
*/
function addStyles(output, styles) {
for (let prop = styles.length - 1; prop >= 0; prop--) {
if (styles[styles[prop]]) {
let url = styles[styles[prop]].replace(regex, '$1' + proxy);
styles[styles[prop]] = url;
}
if (styles[styles[prop]]) {
output.push(styles[prop] + ':' + styles[styles[prop]] + ';');
}
}
}
/**
* Take CSS rules and analyze them, proxy URLs via addStyles(),
* then create matching CSS text for later application to the DOM
*/
function addCSSRules(output, cssRules) {
for (let index = cssRules.length - 1; index >= 0; index--) {
let rule = cssRules[index];
// check for rules with selector
if (rule.type == 1 && rule.selectorText) {
output.push(rule.selectorText + '{');
if (rule.style) {
addStyles(output, rule.style);
}
output.push('}');
// check for @media rules
} else if (rule.type === rule.MEDIA_RULE) {
output.push('@media ' + rule.media.mediaText + '{');
addCSSRules(output, rule.cssRules);
output.push('}');
// check for @font-face rules
} else if (rule.type === rule.FONT_FACE_RULE) {
output.push('@font-face {');
if (rule.style) {
addStyles(output, rule.style);
}
output.push('}');
// check for @keyframes rules
} else if (rule.type === rule.KEYFRAMES_RULE) {
output.push('@keyframes ' + rule.name + '{');
for (let i = rule.cssRules.length - 1; i >= 0; i--) {
let frame = rule.cssRules[i];
if (frame.type === 8 && frame.keyText) {
output.push(frame.keyText + '{');
if (frame.style) {
addStyles(output, frame.style);
}
output.push('}');
}
}
output.push('}');
}
}
}
/**
* Proxy a URL in case it's not a Data URI
*/
function proxyAttribute(url) {
if (/^data:image\//.test(url)) {
return url;
} else {
return proxy + escape(url);
}
}
// Add a hook to enforce proxy for leaky CSS rules
DOMPurify.addHook('uponSanitizeElement', function (node, data) {
if (data.tagName === 'style') {
let output = [];
addCSSRules(output, node.sheet.cssRules);
node.textContent = output.join('\n');
}
});
// Add a hook to enforce proxy for all HTTP leaks incl. inline CSS
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
// Check all src attributes and proxy them
for (let i = 0; i <= attributes.length - 1; i++) {
if (node.hasAttribute(attributes[i])) {
node.setAttribute(
attributes[i],
proxyAttribute(node.getAttribute(attributes[i]))
);
}
}
// Check all style attribute values and proxy them
if (node.hasAttribute('style')) {
let styles = node.style;
let output = [];
for (let prop = styles.length - 1; prop >= 0; prop--) {
// we re-write each property-value pair to remove invalid CSS
if (node.style[styles[prop]] && regex.test(node.style[styles[prop]])) {
let url = node.style[styles[prop]].replace(regex, '$1' + proxy);
node.style[styles[prop]] = url;
}
output.push(styles[prop] + ':' + node.style[styles[prop]] + ';');
}
// re-add styles in case any are left
if (output.length) {
node.setAttribute('style', output.join(''));
} else {
node.removeAttribute('style');
}
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty, config);
```
### Hook to sanitize SVGs shown via an `<img>` tag. [Link](hooks-svg-demo.html)
DOMPurify can be used to sanitize SVGs, but there can be some issues with some of their content and that can be solved via custom hooks and parsing. Also, it's possible to allow some tags which are disabled by default when showing SVGs via an `<img>` tag.
Here is an example which works well for content generated by Illustrator:
```javascript
// Add a hook to post-process a sanitized SVG
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
// Fix namespaces added by Adobe Illustrator
node.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
node.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
});
// Clean SVG string and allow the "filter" tag
const clean = DOMPurify.sanitize(dirty, { ADD_TAGS: ['filter'] });
// Remove partial XML comment left in the HTML
let badTag = clean.indexOf(']>');
let pureSvg = clean.substring(badTag < 0 ? 0 : 5, clean.length);
// Show sanitized content in <img> element
let img = new Image();
img.src = 'data:image/svg+xml;base64,' + window.btoa(pureSvg);
document.getElementById('sanitized').appendChild(img);
```
================================================
FILE: demos/advanced-config-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<!-- Now let's sanitize that content -->
<script>
// Use strict mode
'use strict';
// Import DOMPurify if you're using modules, otherwise assume it's globally available
// import DOMPurify from 'dompurify'; // Uncomment if using ES6 modules
// Specify dirty HTML
const dirty = `
<p kitty-litter="yes" french-fries="no">HELLO</p>
<style>*{x:expression(alert(1))}</style>
<ying><yang><bang>123456</bang></ying></yang>
<iframe/\/src=JavScript:alert(1)></ifrAMe><br>goodbye</p><h1>not me!</h1>
`;
// Specify a configuration directive
const config = {
ALLOWED_TAGS: ['p', '#text'], // only <P> 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;
</script>
</body>
</html>
================================================
FILE: demos/basic-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<!-- Now let's sanitize that content -->
<script>
'use strict';
// Assuming DOMPurify is globally available
// import DOMPurify from 'dompurify'; // Uncomment if using ES6 modules
// Specify dirty HTML
const dirty = '<p>HELLO<iframe/\/src=JavScript:alert(1)></ifrAMe><br>goodbye</p>';
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
document.getElementById('sanitized').innerHTML = clean;
</script>
</body>
</html>
================================================
FILE: demos/config-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<!-- Now let's sanitize that content -->
<script>
'use strict';
// Assuming DOMPurify is globally available
// import DOMPurify from 'dompurify'; // Uncomment if using ES6 modules
// Specify dirty HTML
const dirty = `
<p>HELLO</p><style>*{x:expression(alert(1))}</style>
<iframe/\/src=JavScript:alert(1)></ifrAMe><br>goodbye</p><h1>not me!</h1>
`;
// Specify a configuration directive, only <P> elements allowed
// Note: We want to also keep <p>'s text content, so we add #text too
const config = { ALLOWED_TAGS: ['p', '#text'], KEEP_CONTENT: false };
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty, config);
document.getElementById('sanitized').innerHTML = clean;
</script>
</body>
</html>
================================================
FILE: demos/hooks-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<!-- Now let's sanitize that content -->
<script>
'use strict';
// Assuming DOMPurify is globally available
// import DOMPurify from 'dompurify'; // Uncomment if using ES6 modules
// Specify dirty HTML
const dirty = '<p>HELLO<iframe/\/src=JavScript:alert(1)></ifrAMe><br>goodbye</p>';
// Add a hook to convert all text to capitals
DOMPurify.addHook('beforeSanitizeAttributes', node => {
// Set text node content to uppercase
if (node.nodeName && node.nodeName === '#text') {
node.textContent = node.textContent.toUpperCase();
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
document.getElementById('sanitized').innerHTML = clean;
</script>
</body>
</html>
================================================
FILE: demos/hooks-link-proxy-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<!-- Now let's sanitize that content -->
<script>
'use strict';
// Assuming DOMPurify is globally available
// import DOMPurify from 'dompurify'; // Uncomment if using ES6 modules
const proxy = 'https://my.proxy.service/?';
// Specify dirty HTML
const dirty = `
<a href="http://evil.com/">CLICK</a>
<a href="http://evil.com/" target="jajaja">CLICK</a>
<svg><a xlink:href="http://evil.com/"><circle r=40></a></svg>
<svg><a xlink:href="http://evil.com/" href="http://evil.com/"><circle r=40></a></svg>
<form action="http://evil.com/"><input type="submit"></form>
<map name="test"><area href="http://evil.com/" shape="rect" coords="0,0,200,200"></area></map>
<math href="http://evil.com/">CLICKME</math>
`;
// Add a hook to make all links point to a proxy
DOMPurify.addHook('afterSanitizeAttributes', node => {
// proxy form actions
if ('action' in node) {
node.setAttribute('action', `${proxy}${encodeURIComponent(node.getAttribute('action'))}`);
}
// proxy regular HTML links
if (node.hasAttribute('href')) {
node.setAttribute('href', `${proxy}${encodeURIComponent(node.getAttribute('href'))}`);
}
// proxy SVG/MathML links
if (node.hasAttribute('xlink:href')) {
node.setAttribute('xlink:href', `${proxy}${encodeURIComponent(node.getAttribute('xlink:href'))}`);
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
document.getElementById('sanitized').innerHTML = clean;
</script>
</body>
</html>
================================================
FILE: demos/hooks-mentaljs-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
<!-- Grab the latest version of MentalJS -->
<script src="./lib/Mental.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<div id="test"></div>
<!-- Now let's sanitize that content -->
<script>
'use strict';
// Initialize MentalJS
MentalJS().init({ dom: true, parseInnerHTML: filter });
// Specify dirty HTML
const dirty = `
abc<script>alert('from script:'+location)<\/script>
<img src="xyz" onerror="document.getElementById('test').innerHTML='<img src=123 onerror=alert(/from_innerhtml/);';" />
<img src="xyz" onerror="alert('from img:'+location)">
<img src="xyz" onload="alert\`3\`">
<img src="xyz" onload="">
<script src=//evil.com><\/script>
<script>alert\`4\`<\/script>
<script src=//evil.com>alert(5)<\/script>
<svg><script xlink:href=//evil.com>alert(6)<\/script></svg>
<svg><script href="//evil.com">123<\/script><p>
`;
// Add a hook to sanitize all script content with MentalJS
DOMPurify.addHook('uponSanitizeElement', (node, data) => {
if (data.tagName === 'script') {
const script = node.textContent;
if (!script || 'src' in node.attributes
|| 'href' in node.attributes
|| 'xlink:href' in node.attributes) {
return node.parentNode.removeChild(node);
}
try {
const mental = MentalJS().parse({
options: { eval: false, dom: false },
code: script
});
const scriptNode = document.createElement('script');
scriptNode.appendChild(document.createTextNode(mental));
document.head.appendChild(scriptNode);
return node.parentNode.removeChild(node);
} catch (e) {
return node.parentNode.removeChild(node);
}
}
});
// Add a hook to sanitize all allow-listed events with MentalJS
DOMPurify.addHook('uponSanitizeAttribute', (node, data) => {
if (data.attrName.match(/^on\w+/)) {
const script = data.attrValue;
try {
return data.attrValue = MentalJS().parse({
options: { eval: false, dom: false },
code: script
});
} catch (e) {
return data.attrValue = '';
}
}
});
function filter(dirty) {
const config = {
ADD_TAGS: ['script'],
ADD_ATTR: ['onclick', 'onmouseover', 'onload', 'onunload', 'onerror']
};
const clean = DOMPurify.sanitize(dirty, config);
return clean;
}
document.getElementById('sanitized').innerHTML = filter(dirty);
</script>
</body>
</html>
================================================
FILE: demos/hooks-node-removal-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<!-- Now let's sanitize that content -->
<script>
'use strict';
// Specify dirty HTML
const dirty = '<p>Not empty</p><p class="empty"></p>';
// Add a hook to remove empty nodes
DOMPurify.addHook('beforeSanitizeAttributes', node => {
// Remove the node in case it is empty
if (!node.hasChildNodes() && !node.textContent) {
node.remove();
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
document.getElementById('sanitized').innerHTML = clean;
</script>
</body>
</html>
================================================
FILE: demos/hooks-node-removal2-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our PRE to receive content -->
<pre id="sanitized"></pre>
<!-- Now let's sanitize that content -->
<script>
'use strict';
/**
* In this example, we have some subset of tags that we want to allow, and we have some tags that, if
* encountered, need to be removed completely, including any nested content. An example might be stripping
* out the footer.
*
* We can't simply remove the footer tag from the ALLOWED_TAGS configuration because all that will do is
* strip out the footer tag but leave the nested content. And we can't register 'footer' in the FORBID_TAGS
* config because you can't use both FORBID_TAGS and ALLOWED_TAGS together.
*
* So in this scenario, we only want to allow divs, and we want footers removed entirely.
*/
// Specify dirty HTML
const dirty = '<div><span>This should remain</span><footer>This should be stripped</footer></div>';
// What we want is '<div>This should remain</div>' -- span is removed but content kept, but the footer is
// completely removed.
DOMPurify.setConfig({
ALLOWED_TAGS: [
'div', // because we really want it
'#text', // because we really want it
// 'footer' is added because if not included, the default behavior is to strip
// the tag but keep the content, which we don't want. So, we use a hook for actual
// removal. The hook requires the tag to be an allowed tag or errors are thrown.
'footer'
]
});
/**
* This hook removes the footer element and its children entirely. Note that if we did not also register
* the footer as an allowed tag, we would get an error. So, it's important to do both.
*/
DOMPurify.addHook('uponSanitizeElement', node => {
if (node.tagName === 'FOOTER') {
node.remove();
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
document.getElementById('sanitized').innerText = clean;
</script>
</body>
</html>
================================================
FILE: demos/hooks-proxy-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<!-- Now let's sanitize that content -->
<script>
'use strict';
window.onload = () => {
const dirty = document.getElementById('payload').value;
const proxy = 'https://my.proxy/?url=';
const config = {
FORBID_TAGS: ['svg'],
WHOLE_DOCUMENT: true
};
const attributes = ['action', 'background', 'href', 'poster', 'src', 'srcset'];
const regex = /(url\("?)(?!data:)/gim;
const addStyles = (output, styles) => {
[...styles].reverse().forEach(style => {
if (styles[style]) {
const url = styles[style].replace(regex, `$1${proxy}`);
styles[style] = url;
output.push(`${style}:${styles[style]};`);
}
});
};
const addCSSRules = (output, cssRules) => {
[...cssRules].reverse().forEach(rule => {
switch (rule.type) {
case CSSRule.STYLE_RULE:
output.push(`${rule.selectorText}{`);
if (rule.style) addStyles(output, rule.style);
output.push('}');
break;
case CSSRule.MEDIA_RULE:
output.push(`@media ${rule.media.mediaText}{`);
addCSSRules(output, rule.cssRules);
output.push('}');
break;
case CSSRule.FONT_FACE_RULE:
output.push('@font-face {');
if (rule.style) addStyles(output, rule.style);
output.push('}');
break;
case CSSRule.KEYFRAMES_RULE:
output.push(`@keyframes ${rule.name}{`);
[...rule.cssRules].reverse().forEach(frame => {
if (frame.type === CSSRule.KEYFRAME_RULE && frame.keyText) {
output.push(`${frame.keyText}{`);
if (frame.style) addStyles(output, frame.style);
output.push('}');
}
});
output.push('}');
break;
default:
break;
}
});
};
const proxyAttribute = url => /^data:image\//.test(url) ? url : `${proxy}${escape(url)}`;
DOMPurify.addHook('uponSanitizeElement', (node, data) => {
if (data.tagName === 'style') {
const output = [];
addCSSRules(output, node.sheet.cssRules);
node.textContent = output.join("\n");
}
});
DOMPurify.addHook('afterSanitizeAttributes', node => {
attributes.forEach(attribute => {
if (node.hasAttribute(attribute)) {
node.setAttribute(attribute, proxyAttribute(node.getAttribute(attribute)));
}
});
if (node.hasAttribute('style')) {
const styles = node.style;
const output = [];
[...styles].reverse().forEach(style => {
if (styles[style] && regex.test(styles[style])) {
const url = styles[style].replace(regex, `$1${proxy}`);
styles[style] = url;
}
output.push(`${style}:${styles[style]};`);
});
node.setAttribute('style', output.join('') || node.removeAttribute('style'));
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty, config);
document.getElementById('sanitized').innerHTML = clean;
};
</script>
<!-- Here we cage our payload in a TEXTAREA -->
<textarea id="payload">
<!DOCTYPE html SYSTEM "https://leaking.via/doctype">
<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://leaking.via/html-manifest">
<head>
<!--
%Base (check manually)
-->
<base href="https://leaking.via/base-href/">
<!--
%MSIE Imports
-->
<?IMPORT namespace="myNS" implementation="https://leaking.via/import-implementation" ?>
<IMPORT namespace="myNS" implementation="https://leaking.via/import-implementation-2" />
<!--
%Redirects
-->
<meta http-equiv="refresh" content="10; url=http://leaking.via/meta-refresh">
<!--
%CSP
-->
<meta http-equiv="Content-Security-Policy" content="script-src 'self'; report-uri http://leaking.via/meta-csp-report-uri">
<meta http-equiv="Content-Security-Policy-Report-Only" content="script-src 'self'; report-uri http://leaking.via/meta-csp-report-uri-2">
<!--
%Reading View
-->
<meta name="copyright" content="<img src='https://leaking.via/meta-name-copyright-reading-view'>">
<meta name="displaydate" content="<img src='https://leaking.via/meta-name-displaydate-reading-view'>">
<meta property="og:site_name" content="<img src='https://leaking.via/meta-property-reading-view'>">
<!--
%Links
-->
<link rel="stylesheet" href="https://leaking.via/link-stylesheet" />
<link rel="icon" href="https://leaking.via/link-icon" />
<link rel="canonical" href="https://leaking.via/link-canonical" />
<link rel="shortcut icon" href="https://leaking.via/link-shortcut-icon" />
<link rel="import" href="https://leaking.via/link-import" />
<link rel="dns-prefetch" href="https://leaking.via/link-dns-prefetch" />
<link rel="preconnect" href="https://leaking.via/link-preconnect">
<link rel="prefetch" href="https://leaking.via/link-prefetch" />
<link rel="preload" href="https://leaking.via/link-preload" />
<link rel="prerender" href="https://leaking.via/link-prerender" />
<link rel="search" href="https://leaking.via/link-search" />
<!--
Note that OpenSearch description URLs are ignored in Chrome if this file isn't placed in the webroot.
Also, in Chrome, you won't see the request in the developer tools because the request happens in the privileged browser process.
Use a network sniffer to detect it.
-->
<link rel="alternate" href="https://leaking.via/link-alternate" />
<link rel="alternate" type="application/atom+xml" href="https://leaking.via/link-alternate-atom" />
<link rel="alternate stylesheet" href="https://leaking.via/link-alternate-stylesheet" />
<link rel="appendix" href="https://leaking.via/link-appendix" />
<link rel="apple-touch-icon-precomposed" href="https://leaking.via/link-apple-touch-icon-precomposed">
<link rel="apple-touch-icon" href="https://leaking.via/link-apple-touch-icon">
<link rel="archives" href="https://leaking.via/link-archives" />
<link rel="author" href="https://leaking.via/link-author" />
<link rel="bookmark" href="https://leaking.via/link-bookmark" />
<link rel="chapter" href="https://leaking.via/link-chapter" />
<link rel="contents" href="https://leaking.via/link-contents" />
<link rel="copyright" href="https://leaking.via/link-copyright" />
<link rel="entry-content" href="https://leaking.via/link-entry-content" />
<link rel="external" href="https://leaking.via/link-external" />
<link rel="feedurl" href="https://leaking.via/link-feedurl" />
<link rel="first" href="https://leaking.via/link-first" />
<link rel="glossary" href="https://leaking.via/link-glossary" />
<link rel="help" href="https://leaking.via/link-help" />
<link rel="index" href="https://leaking.via/link-index" />
<link rel="last" href="https://leaking.via/link-last" />
<link rel="manifest" href="https://leaking.via/link-manifest" />
<link rel="next" href="https://leaking.via/link-next" />
<link rel="offline" href="https://leaking.via/link-offline" />
<link rel="pingback" href="https://leaking.via/link-pingback" />
<link rel="prev" href="https://leaking.via/link-prev" />
<link rel="search" type="application/opensearchdescription+xml" href="https://leaking.via/link-search-2" title="Search" />
<link rel="sidebar" href="https://leaking.via/link-sidebar" />
<link rel="start" href="https://leaking.via/link-start" />
<link rel="section" href="https://leaking.via/link-section" />
<link rel="subsection" href="https://leaking.via/link-subsection" />
<link rel="subresource" href="https://leaking.via/link-subresource">
<link rel="tag" href="https://leaking.via/link-tag" />
<link rel="up" href="https://leaking.via/link-up" />
</head>
<!--
%Body Background
-->
<body background="https://leaking.via/body-background">
<!--
%Links & Maps
-->
<a ping="http://leaking.via/a-ping" href="#">You have to click me</a>
<img src="data:;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw" width="150" height="150" usemap="#map">
<map name="map">
<area ping="http://leaking.via/area-ping" shape="rect" coords="0,0,150,150" href="#">
</map>
<!--
The ping attribute allows to send a HTTP request to an external IP or domain,
even if the link's HREF points somewhere else. The link has to be clicked though
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-ping
-->
<!--
%Table Background
-->
<table background="https://leaking.via/table-background">
<tr>
<td background="https://leaking.via/td-background"></td>
</tr>
</table>
<!--
%Images
-->
<img src="https://leaking.via/img-src">
<img dynsrc="https://leaking.via/img-dynsrc">
<img lowsrc="https://leaking.via/img-lowsrc">
<img src="data:image/svg+xml,<svg%20xmlns='%68ttp:%2f/www.w3.org/2000/svg'%20xmlns:xlink='%68ttp:%2f/www.w3.org/1999/xlink'><image%20xlink:hr%65f='%68ttp:%2f/leaking.via/svg-via-data'></image></svg>">
<image src="https://leaking.via/image-src">
<image href="https://leaking.via/image-href">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<image href="https://leaking.via/svg-image-href">
<image xlink:href="https://leaking.via/svg-image-xlink-href">
</svg>
<picture>
<source srcset="https://leaking.via/picture-source-srcset">
</picture>
<picture>
<img srcset="https://leaking.via/picture-img-srcset">
</picture>
<img srcset=",,,,,https://leaking.via/img-srcset">
<img src="#" longdesc="https://leaking.via/img-longdesc">
<!-- longdesc works on Firefox but requires right-click, "View Description" -->
<!--
%Forms
-->
<form action="https://leaking.via/form-action">
<button form="test" formaction="https://leaking.via/button-formaction">CLICKME</button>
</form>
<form id="test"></form>
<input type="image" src="https://leaking.via/input-src" name="test" value="test">
<isindex src="https://leaking.via/isindex" type="image">
<!--
%Media
-->
<bgsound src="https://leaking.via/bgsound-src"></bgsound>
<video src="https://leaking.via/video-src">
<track kind="subtitles" label="English subtitles" src="https://leaking.via/track-src" srclang="en" default></track>
</video>
<video controls>
<source src="https://leaking.via/video-source-src" type="video/mp4">
</video>
<audio controls>
<source src="https://leaking.via/audio-source-src" type="video/mp4">
</audio>
<video poster="https://leaking.via/video-poster" src="https://leaking.via/video-poster-2"></video>
<!--
%Object & Embed
-->
<object data="https://leaking.via/object-data"></object>
<object type="text/x-scriptlet" data="https://leaking.via/object-data-x-scriptlet"></object>
<object movie="https://leaking.via/object-movie" type="application/x-shockwave-flash"></object>
<object movie="https://leaking.via/object-movie">
<param name="type" value="application/x-shockwave-flash"></param>
</object>
<object codebase="https://leaking.via/object-codebase"></object>
<embed src="https://leaking.via/embed-src"></embed>
<embed code="https://leaking.via/embed-code"></embed>
<object classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name="DataURL" value="http://leaking.via/object-param-dataurl">
</object>
<!--
%Script
-->
<script src="https://leaking.via/script-src"></script>
<svg><script href="https://leaking.via/svg-script-href"></script></svg>
<svg><script xlink:href="https://leaking.via/svg-script-xlink-href"></script></svg>
<!--
%Frames
-->
<iframe src="https://leaking.via/iframe-src"></iframe>
<iframe src="data:image/svg+xml,<svg%20xmlns='%68ttp:%2f/www.w3.org/2000/svg'%20xmlns:xlink='%68ttp:%2f/www.w3.org/1999/xlink'><image%20xlink:hr%65f='%68ttps:%2f/leaking.via/svg-via-data'></image></svg>"></iframe>
<iframe srcdoc="<img src=https://leaking.via/iframe-srcdoc-img-src>"></iframe>
<frameset>
<frame src="https://leaking.via/frame-src"></frame>
</frameset>
<iframe src="view-source:https://leaking.via/iframe-src-viewsource"></iframe>
<!--
%CSS
-->
<style>
@import 'https://leaking.via/css-import-string';
@import url(https://leaking.via/css-import-url);
</style>
<style>
a:after {content: url(https://leaking.via/css-after-content)}
a::after {content: url(https://leaking.via/css-after-content-2)}
a:before {content: url(https://leaking.via/css-before-content)}
a::before {content: url(https://leaking.via/css-before-content-2)}
</style>
<a href="#">ABC</a>
<style>
big {
list-style: url(https://leaking.via/css-list-style);
list-style-image: url(https://leaking.via/css-list-style-image);
background: url(https://leaking.via/css-background);
background-image: url(https://leaking.via/css-background-image);
border-image: url(https://leaking.via/css-border-image);
border-image-source: url(https://leaking.via/css-border-image-source);
shape-outside: url(https://leaking.via/css-shape-outside);
cursor: url(https://leaking.via/css-cursor), auto;
}
</style>
<big>DEF</big>
<style>
@font-face {
font-family: leak;
src: url(https://leaking.via/css-font-face-src);
}
big {
font-family: leak;
}
</style>
<big>GHI</big>
<svg>
<style>
circle {
fill: url(https://leaking.via/svg-css-fill#foo);
mask: url(https://leaking.via/svg-css-mask#foo);
filter: url(https://leaking.via/svg-css-filter#foo);
clip-path: url(https://leaking.via/svg-css-clip-path#foo);
}
</style>
<circle r="40"></circle>
</svg>
<s foo="https://leaking.via/css-attr-notation">JKL</s>
<style>
s {
--leak: url(https://leaking.via/css-variables);
}
s {
background: var(--leak);
}
s::after {
content: attr(foo url);
}
s::before {
content: attr(notpresent, url(https://leaking.via/css-attr-fallback));
}
</style>
<style>
@media all, not print and not monochrome, (min-width: 1px) {
body {
background: url(https://leaking.via/css-media-query);
-webkit-animation: rotate-a-bit;
-webkit-animation-duration: 1s;
}
}
@media some garbage {
more garbage;
}
@-webkit-keyframes rotate-a-bit {
0% { transform: translate(0deg); background: url(https://leaking.via/keyframe-0) }
100% { transform: rotate(0deg); background: url(https://leaking.via/keyframe-100) }
}
</style>
<!--
%Inline CSS
-->
<b style="
list-style: url(https://leaking.via/inline-css-list-style);
list-style-image: url(https://leaking.via/inline-css-list-style-image);
background: url(https://leaking.via/inline-css-background);
background-image: url(https://leaking.via/inline-css-background-image);
border-image: url(https://leaking.via/inline-css-list-style-image);
border-image-source: url(https://leaking.via/inline-css-border-image-source);
shape-outside: url(https://leaking.via/inline-css-shape-outside);
cursor: url(https://leaking.via/inline-css-cursor), auto;
">JKL</b>
<svg>
<circle style="
fill: url(https://leaking.via/svg-inline-css-fill#foo);
mask: url(https://leaking.via/svg-inline-css-mask#foo);
filter: url(https://leaking.via/svg-inline-css-filter#foo);
clip-path: url(https://leaking.via/svg-inline-css-clip-path#foo);
"></circle>
</svg>
<!--
%Exotic Inline CSS
-->
<div style="background: url() url() url() url() url(https://leaking.via/inline-css-multiple-backgrounds);"></div>
<div style="behavior: url('https://leaking.via/inline-css-behavior');"></div>
<div style="-ms-behavior: url('https://leaking.via/inline-css-behavior-2');"></div>
<div style="background-image: image('https://leaking.via/inline-css-image-function')"></div>
<div style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader( src='https://leaking.via/inline-css-filter-alpha', sizingMethod='scale');" ></div>
<div style="filter:progid:DXImageTransform.Microsoft.ICMFilter(colorSpace='https://leaking.via/inline-css-filter-icm')"></div>
<!--
%Applet
-->
<applet code="Test" codebase="https://leaking.via/applet-codebase"></applet>
<applet code="Test" archive="https://leaking.via/applet-archive"></applet>
<applet code="Test" object="https://leaking.via/applet-object"></applet>
<!--
%SVG
-->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<linearGradient id="Gradient">
<stop offset="0" stop-color="white" stop-opacity="0" />
<stop offset="1" stop-color="white" stop-opacity="1" />
</linearGradient>
<mask id="Mask">
<rect x="0" y="0" width="200" height="200" fill="url(https://leaking.via/svg-fill)" />
</mask>
</defs>
<rect x="0" y="0" width="200" height="200" fill="green" />
<rect x="0" y="0" width="200" height="200" fill="red" mask="url(https://leaking.via/svg-mask)" />
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<image xmlns:xlink="http://www.w3.org/1999/xlink">
<set attributeName="xlink:href" begin="0s" to="https://leaking.via/svg-image-set" />
</image>
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<image xmlns:xlink="http://www.w3.org/1999/xlink">
<animate attributeName="xlink:href" begin="0s" from="#" to="https://leaking.via/svg-image-animate" />
</image>
</svg>
<!--
%XSLT Stylesheets
-->
<?xml-stylesheet type="text/xsl" href="https://leaking.via/xslt-stylesheet" ?>
<!--
%Data Islands
-->
<xml src="https://leaking.via/xml-src" id="xml"></xml>
<div datasrc="#xml" datafld="$text" dataformatas="html"></div>
</textarea>
</body>
</html>
================================================
FILE: demos/hooks-removal-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<!-- Now let's sanitize that content -->
<script>
'use strict';
// Specify dirty HTML
const dirty = '<p>HELLO<iframe/\/src=JavScript:alert(1)></ifrAMe><br>goodbye</p>';
// Function to convert text to uppercase
const uppercaseHook = (node) => {
if (node.nodeName && node.nodeName === '#text') {
node.textContent = node.textContent.toUpperCase();
}
};
// Function to wrap text in <big> tags
const bigHook = (node) => {
if (node.nodeName && node.nodeName === '#text') {
node.textContent = node.textContent.big();
}
};
// Function to wrap text in <strong> tags
const strongHook = (node) => {
if (node.nodeName && node.nodeName === '#text') {
node.textContent = node.textContent.bold();
}
};
// Adding and removing hooks with DOMPurify
DOMPurify.addHook('beforeSanitizeAttributes', uppercaseHook);
let clean = DOMPurify.sanitize(dirty);
document.getElementById('sanitized').innerHTML += clean;
DOMPurify.removeHook('beforeSanitizeAttributes');
// Demonstrating adding multiple hooks
DOMPurify.addHook('beforeSanitizeAttributes', uppercaseHook);
DOMPurify.addHook('beforeSanitizeAttributes', bigHook);
DOMPurify.addHook('beforeSanitizeElements', strongHook);
clean = DOMPurify.sanitize(dirty);
document.getElementById('sanitized').innerHTML += clean;
DOMPurify.removeHooks('beforeSanitizeAttributes');
// Adding hooks and then using removeAllHooks
DOMPurify.addHook('beforeSanitizeAttributes', uppercaseHook);
DOMPurify.addHook('beforeSanitizeAttributes', bigHook);
clean = DOMPurify.sanitize(dirty);
document.getElementById('sanitized').innerHTML += clean;
DOMPurify.removeAllHooks();
clean = DOMPurify.sanitize(dirty);
document.getElementById('sanitized').innerHTML += clean;
</script>
</body>
</html>
================================================
FILE: demos/hooks-sanitize-css-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<!-- Now let's sanitize that content -->
<script>
/* jshint globalstrict:true */
/* global DOMPurify */
'use strict';
window.onload = function(){
// Specify dirty HTML
let dirty = document.getElementById('payload').value;
// We can allow all (default elements) but SVG
const config = {
FORBID_TAGS: ['svg'] // SVG is not yet supported. Too messy.
};
// Specify CSS property whitelist
const allowed_properties = [
'color',
'background',
'border',
'padding',
'margin',
'font-family',
'content',
'padding'
];
// Specify if CSS functions are permitted
const allow_css_functions = true;
/**
* Take CSS property-value pairs and validate against white-list,
* then add the styles to an array of property-value pairs
*/
function validateStyles(output, styles) {
Object.keys(styles).forEach(function(index) {
if (styles.hasOwnProperty(index)) {
let normalizedKey = styles[index].replace(/([A-Z])/g, '-$1').toLowerCase();
if (allowed_properties.includes(normalizedKey)) {
let value = styles[normalizedKey];
output.push(`${normalizedKey}:${value};`);
}
}
});
}
/**
* Take CSS rules and analyze them, create string wrapper to
* apply them to the DOM later on. Note that only selector rules
* are supported right now
*/
function addCSSRules(output, cssRules) {
Array.from(cssRules).reverse().forEach(rule => {
// check for rules with selector
if (rule.type === 1 && rule.selectorText) {
output.push(`${rule.selectorText}{`);
if (rule.style) {
validateStyles(output, rule.style);
}
output.push('}');
}
});
}
// Add a hook to enforce CSS element sanitization
DOMPurify.addHook('uponSanitizeElement', function(node, data) {
if (data.tagName === 'style') {
let output = [];
addCSSRules(output, node.sheet.cssRules);
node.textContent = output.join("\n");
}
});
// Add a hook to enforce CSS attribute sanitization
DOMPurify.addHook('afterSanitizeAttributes', function(node) {
// Nasty hack to fix baseURI + CSS problems in Chrome
if (!node.ownerDocument.baseURI) {
let base = document.createElement('base');
base.href = document.baseURI;
node.ownerDocument.head.appendChild(base);
}
// Check all style attribute values and validate them
if (node.hasAttribute('style')) {
let output = [];
validateStyles(output, node.style);
// re-add styles in case any are left
if (output.length) {
node.setAttribute('style', output.join(""));
} else {
node.removeAttribute('style');
}
}
});
// Clean HTML string and write into our DIV
let clean = DOMPurify.sanitize(dirty, config);
document.getElementById('sanitized').innerHTML = clean;
}
</script>
<!-- Here we cage our payload in a TEXTAREA -->
<textarea id="payload">
<a href="#" style="border:1ps solid blue;color:red;background:url(/images/test.gif)">ABC</a>
<style>
big {
list-style: url(https://leaking.via/css-list-style);
list-style-image: url(https://leaking.via/css-list-style-image);
background: url(https://leaking.via/css-background);
background-image: url(https://leaking.via/css-background-image);
border-image: url(https://leaking.via/css-border-image);
border-image-source: url(https://leaking.via/css-border-image-source);
shape-outside: url(https://leaking.via/css-shape-outside);
cursor: url(https://leaking.via/css-cursor), auto;
color:red;
}
</style>
<big>DEF</big>
<svg>
<style>
circle {
fill: green;
mask: url(https://leaking.via/svg-css-mask#foo);
filter: url(https://leaking.via/svg-css-filter#foo);
clip-path: url(https://leaking.via/svg-css-clip-path#foo);
}
</style>
<circle r="40"></circle>
</svg>
<style>
@media all, not print and not monochrome, (min-width: 1px) {
body {
background: url(https://leaking.via/css-media-query);
font-family: expression(alert('url()'));
-webkit-animation: rotate-a-bit;
-webkit-animation-duration: 1s;
}
}
@font-face {
font-family: leak;
src: url(test.woff);
}
strong {
font-family: leak;
color:blue;
background: url("/images/test.gif");
}
strong:after {
content: 'hola!';
}
</style>
<strong>GHI</strong>
</textarea>
</body>
</html>
================================================
FILE: demos/hooks-scheme-allowlist.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<!-- Now let's sanitize that content -->
<script>
'use strict';
// Specify dirty HTML
const dirty = `
<a href="foo:?a">INSECURE</a>
<a href="ftp://abc.de?a">SECURE</a>
<a href="https://abc.de?a">SECURE</a>
<a href="?a">SECURE</a>
<svg><a href="ms-appx://some/app/test.html"><circle r=40 fill=red></a></svg>
<svg><a href="http://benign.com/"><circle r=40 fill=green></a></svg>
<svg><a href="#123"><circle r=40 fill=green></a></svg>
<form action="?form"><input type="submit" value="safe"></form>
<form action="bingweather:?lat=1&long=2"><input type="submit" value="unsafe"></form>
<img src="404" width="200" height="200" usemap="#test">
<map name="test"><area href="skype://123456?call" shape="rect" coords="0,0,200,200"></area></map>
<img src="404" width="200" height="200" usemap="#test">
<map name="test"><area href="http://test.com/" shape="rect" coords="0,0,200,200"></area></map>
<math href="http://test.com/">SECURE</math>
<math href="calculator:">INSECURE</math>
<math><mi target="xxx" href="http://test.com/">SECURE</mi></math>
<math><mi href="javascript:alert(1)">INSECURE</mi></math>
<math><mi target="xxx" href="aim:1111111?call">INSECURE</mi></math>
<svg xmlns:xlink="http://www.w3.org/1999/xlink"><a xlink:href="https://test.com/"><circle r=40 fill=green></a></svg>
<svg xmlns:xlink="http://www.w3.org/1999/xlink"><a xlink:href="telnet:1.1.1.1"><circle r=40 fill=red></a></svg>
<svg xmlns:xlink="http://www.w3.org/1999/xlink"><a xlink:href="?secure"><circle r=40 fill=green></a></svg>
`;
// Allowed URI schemes
const allowlist = ['http', 'https', 'ftp'];
// Build fitting regex
const regex = RegExp(`^(${allowlist.join('|')}):`, 'im');
// Add a hook to enforce URI scheme allow-list
DOMPurify.addHook('afterSanitizeAttributes', node => {
// Build an anchor to map URLs to
const anchor = document.createElement('a');
// Check all href attributes for validity
if (node.hasAttribute('href')) {
anchor.href = node.getAttribute('href');
if (anchor.protocol && !anchor.protocol.match(regex)) {
node.removeAttribute('href');
}
}
// Check all action attributes for validity
if (node.hasAttribute('action')) {
anchor.href = node.getAttribute('action');
if (anchor.protocol && !anchor.protocol.match(regex)) {
node.removeAttribute('action');
}
}
// Check all xlink:href attributes for validity
if (node.hasAttribute('xlink:href')) {
anchor.href = node.getAttribute('xlink:href');
if (anchor.protocol && !anchor.protocol.match(regex)) {
node.removeAttribute('xlink:href');
}
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
document.getElementById('sanitized').innerHTML = clean;
</script>
</body>
</html>
================================================
FILE: demos/hooks-target-blank-demo.html
================================================
<!doctype html>
<html>
<head>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
<div id="sanitized"></div>
<!-- Now let's sanitize that content -->
<script>
'use strict';
// Specify dirty HTML
const dirty = `
<a href="?a">CLICK</a>
<a href="?a" target="jajaja">CLICK</a>
<svg><a href="?svg"><circle r=40></a></svg>
<form action="?form"><input type="submit"></form>
<img src="404" width="200" height="200" usemap="#test">
<map name="test"><area href="?area" shape="rect" coords="0,0,200,200"></area></map>
<math href="?mathml">CLICKME</math>
<math><mi href="?mathml">CLICKME</mi></math>
<math><mi target="xxx" href="?mathml">CLICKME</mi></math>
<svg xmlns:xlink="http://www.w3.org/2000/svg"><a xlink:href="?bla"><circle r=40></a></svg>
`;
// Add a hook to make all links open a new window
DOMPurify.addHook('afterSanitizeAttributes', (node) => {
if ('target' in node) {
node.setAttribute('target', '_blank');
node.setAttribute('rel', 'noopener noreferrer');
}
if (!node.hasAttribute('target') && (node.hasAttribute('xlink:href') || node.hasAttribute('href'))) {
node.setAttribute('xlink:show', 'new');
}
});
// Clean HTML string and write into our DIV
const clean = DOMPurify.sanitize(dirty);
document.getElementById('sanitized').innerHTML = clean;
</script>
</body>
</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
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
SYMBOL INDEX (134 symbols across 14 files)
FILE: demos/lib/Mental.js
function Mental (line 5783) | function Mental() {
FILE: dist/purify.cjs.d.ts
type Config (line 8) | interface Config {
type UseProfilesConfig (line 196) | interface UseProfilesConfig {
type DOMPurify (line 217) | interface DOMPurify {
type RemovedElement (line 398) | interface RemovedElement {
type RemovedAttribute (line 407) | interface RemovedAttribute {
type BasicHookName (line 417) | type BasicHookName = 'beforeSanitizeElements' | 'afterSanitizeElements' ...
type ElementHookName (line 418) | type ElementHookName = 'beforeSanitizeAttributes' | 'afterSanitizeAttrib...
type DocumentFragmentHookName (line 419) | type DocumentFragmentHookName = 'beforeSanitizeShadowDOM' | 'afterSaniti...
type UponSanitizeElementHookName (line 420) | type UponSanitizeElementHookName = 'uponSanitizeElement';
type UponSanitizeAttributeHookName (line 421) | type UponSanitizeAttributeHookName = 'uponSanitizeAttribute';
type HookName (line 422) | type HookName = BasicHookName | ElementHookName | DocumentFragmentHookNa...
type NodeHook (line 423) | type NodeHook = (this: DOMPurify, currentNode: Node, hookEvent: null, co...
type ElementHook (line 424) | type ElementHook = (this: DOMPurify, currentNode: Element, hookEvent: nu...
type DocumentFragmentHook (line 425) | type DocumentFragmentHook = (this: DOMPurify, currentNode: DocumentFragm...
type UponSanitizeElementHook (line 426) | type UponSanitizeElementHook = (this: DOMPurify, currentNode: Node, hook...
type UponSanitizeAttributeHook (line 427) | type UponSanitizeAttributeHook = (this: DOMPurify, currentNode: Element,...
type UponSanitizeElementHookEvent (line 428) | interface UponSanitizeElementHookEvent {
type UponSanitizeAttributeHookEvent (line 432) | interface UponSanitizeAttributeHookEvent {
type WindowLike (line 442) | type WindowLike = Pick<typeof globalThis, 'DocumentFragment' | 'HTMLTemp...
FILE: dist/purify.cjs.js
function unapply (line 67) | function unapply(func) {
function unconstruct (line 84) | function unconstruct(Func) {
function addToSet (line 100) | function addToSet(set, array) {
function cleanArray (line 131) | function cleanArray(array) {
function clone (line 146) | function clone(object) {
function lookupGetter (line 169) | function lookupGetter(object, prop) {
constant MUSTACHE_EXPR (line 208) | const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
constant ERB_EXPR (line 209) | const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
constant TMPLIT_EXPR (line 210) | const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm);
constant DATA_ATTR (line 211) | const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
constant ARIA_ATTR (line 212) | const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
constant IS_ALLOWED_URI (line 213) | const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|c...
constant IS_SCRIPT_OR_DATA (line 215) | const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
constant ATTR_WHITESPACE (line 216) | const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2...
constant DOCTYPE_NAME (line 218) | const DOCTYPE_NAME = seal(/^html$/i);
constant CUSTOM_ELEMENT (line 219) | const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
constant NODE_TYPE (line 237) | const NODE_TYPE = {
method createHTML (line 279) | createHTML(html) {
method createScriptURL (line 282) | createScriptURL(scriptUrl) {
function createDOMPurify (line 307) | function createDOMPurify() {
FILE: dist/purify.es.mjs
function unapply (line 65) | function unapply(func) {
function unconstruct (line 82) | function unconstruct(Func) {
function addToSet (line 98) | function addToSet(set, array) {
function cleanArray (line 129) | function cleanArray(array) {
function clone (line 144) | function clone(object) {
function lookupGetter (line 167) | function lookupGetter(object, prop) {
constant MUSTACHE_EXPR (line 206) | const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
constant ERB_EXPR (line 207) | const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
constant TMPLIT_EXPR (line 208) | const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm);
constant DATA_ATTR (line 209) | const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
constant ARIA_ATTR (line 210) | const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
constant IS_ALLOWED_URI (line 211) | const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|c...
constant IS_SCRIPT_OR_DATA (line 213) | const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
constant ATTR_WHITESPACE (line 214) | const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2...
constant DOCTYPE_NAME (line 216) | const DOCTYPE_NAME = seal(/^html$/i);
constant CUSTOM_ELEMENT (line 217) | const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
constant NODE_TYPE (line 235) | const NODE_TYPE = {
method createHTML (line 277) | createHTML(html) {
method createScriptURL (line 280) | createScriptURL(scriptUrl) {
function createDOMPurify (line 305) | function createDOMPurify() {
FILE: dist/purify.js
function unapply (line 71) | function unapply(func) {
function unconstruct (line 88) | function unconstruct(Func) {
function addToSet (line 104) | function addToSet(set, array) {
function cleanArray (line 135) | function cleanArray(array) {
function clone (line 150) | function clone(object) {
function lookupGetter (line 173) | function lookupGetter(object, prop) {
method createHTML (line 283) | createHTML(html) {
method createScriptURL (line 286) | createScriptURL(scriptUrl) {
function createDOMPurify (line 311) | function createDOMPurify() {
FILE: rollup.config.js
method transform (line 27) | transform(code, id) {
FILE: scripts/fix-types.js
function fixCjsTypes (line 19) | async function fixCjsTypes(fileName) {
FILE: src/config.ts
type Config (line 8) | interface Config {
type UseProfilesConfig (line 239) | interface UseProfilesConfig {
FILE: src/purify.ts
constant NODE_TYPE (line 39) | const NODE_TYPE = {
method createHTML (line 90) | createHTML(html) {
method createScriptURL (line 93) | createScriptURL(scriptUrl) {
function createDOMPurify (line 122) | function createDOMPurify(window: WindowLike = getGlobal()): DOMPurify {
type DOMPurify (line 1750) | interface DOMPurify {
type RemovedElement (line 1977) | interface RemovedElement {
type RemovedAttribute (line 1987) | interface RemovedAttribute {
type BasicHookName (line 1999) | type BasicHookName =
type ElementHookName (line 2003) | type ElementHookName = 'beforeSanitizeAttributes' | 'afterSanitizeAttrib...
type DocumentFragmentHookName (line 2004) | type DocumentFragmentHookName =
type UponSanitizeElementHookName (line 2007) | type UponSanitizeElementHookName = 'uponSanitizeElement';
type UponSanitizeAttributeHookName (line 2008) | type UponSanitizeAttributeHookName = 'uponSanitizeAttribute';
type HooksMap (line 2010) | interface HooksMap {
type ArrayElement (line 2022) | type ArrayElement<T> = T extends Array<infer U> ? U : never;
type HookFunction (line 2024) | type HookFunction = ArrayElement<HooksMap[keyof HooksMap]>;
type HookName (line 2026) | type HookName =
type NodeHook (line 2033) | type NodeHook = (
type ElementHook (line 2040) | type ElementHook = (
type DocumentFragmentHook (line 2047) | type DocumentFragmentHook = (
type UponSanitizeElementHook (line 2054) | type UponSanitizeElementHook = (
type UponSanitizeAttributeHook (line 2061) | type UponSanitizeAttributeHook = (
type UponSanitizeElementHookEvent (line 2068) | interface UponSanitizeElementHookEvent {
type UponSanitizeAttributeHookEvent (line 2073) | interface UponSanitizeAttributeHookEvent {
type WindowLike (line 2084) | type WindowLike = Pick<
FILE: src/regexp.ts
constant MUSTACHE_EXPR (line 4) | const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
constant ERB_EXPR (line 5) | const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
constant TMPLIT_EXPR (line 6) | const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm);
constant DATA_ATTR (line 7) | const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
constant ARIA_ATTR (line 8) | const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
constant IS_ALLOWED_URI (line 9) | const IS_ALLOWED_URI = seal(
constant IS_SCRIPT_OR_DATA (line 12) | const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
constant ATTR_WHITESPACE (line 13) | const ATTR_WHITESPACE = seal(
constant DOCTYPE_NAME (line 16) | const DOCTYPE_NAME = seal(/^html$/i);
constant CUSTOM_ELEMENT (line 17) | const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
FILE: src/utils.ts
function unapply (line 67) | function unapply<T>(
function unconstruct (line 85) | function unconstruct<T>(
function addToSet (line 99) | function addToSet(
function cleanArray (line 138) | function cleanArray<T>(array: T[]): Array<T | null> {
function clone (line 156) | function clone<T extends Record<string, any>>(object: T): T {
function lookupGetter (line 187) | function lookupGetter<T extends Record<string, any>>(
FILE: test/bootstrap-test-suite.js
class StringWrapper (line 4) | class StringWrapper {
method constructor (line 5) | constructor(s) {
method toString (line 9) | toString() {
function loadDOMPurify (line 14) | function loadDOMPurify(
function loadDOMPurifyWithSanityCheck (line 50) | function loadDOMPurifyWithSanityCheck(
method createPolicy (line 100) | createPolicy(name, rules) {
method createPolicy (line 132) | createPolicy(name, rules) {
method createScript (line 151) | createScript(s) {
method createHTML (line 167) | createHTML(s) {
method createHTML (line 183) | createHTML(s) {
method createScriptURL (line 187) | createScriptURL(s) {
method createHTML (line 211) | createHTML(s) {
method createScriptURL (line 215) | createScriptURL(s) {
method createPolicy (line 237) | createPolicy(name, rules) {
method createHTML (line 254) | createHTML(s) {
method createScriptURL (line 257) | createScriptURL(s) {
FILE: test/jsdom-node.js
function startQUnit (line 19) | async function startQUnit() {
FILE: typescript/verify.js
function run (line 13) | async function run() {
function verify (line 45) | async function verify(name, directory) {
function compile (line 70) | async function compile(configFileName) {
function printDiagnostics (line 103) | function printDiagnostics(diagnostics) {
Condensed preview — 83 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,046K chars).
[
{
"path": ".babelrc",
"chars": 252,
"preview": "{\n \"presets\": [\n [\n \"@babel/preset-env\",\n {\n \"targets\": {\n \"chrome\": 51,\n \"firefo"
},
{
"path": ".editorconfig",
"chars": 174,
"preview": "# http://EditorConfig.org\n\nroot = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\nindent_size = 2\nindent_style = space\ninsert"
},
{
"path": ".gitattributes",
"chars": 14,
"preview": "* text eol=lf\n"
},
{
"path": ".github/FUNDING.yml",
"chars": 15,
"preview": "github: cure53\n"
},
{
"path": ".github/ISSUE_TEMPLATE.md",
"chars": 498,
"preview": "> This issue proposes a [bug, feature] which...\n\n### Background & Context\n\nPlease provide some more detailed information"
},
{
"path": ".github/PULL_REQUEST_TEMPLATE.md",
"chars": 474,
"preview": "## Summary\n\n<!-- Explain this change, e.g. \"this pull request [implements, fixes, changes]...\". -->\n\n## Background & Con"
},
{
"path": ".github/dependabot.yml",
"chars": 112,
"preview": "version: 2\nupdates:\n- package-ecosystem: \"github-actions\"\n directory: \"/\"\n schedule:\n interval: \"weekly\"\n"
},
{
"path": ".github/workflows/build-and-test.yml",
"chars": 1296,
"preview": "name: Build and Test\n\n# The event triggers are configured as following:\n# - on `main` -> trigger the workflow on every p"
},
{
"path": ".github/workflows/codeql-analysis.yml",
"chars": 1992,
"preview": "name: \"CodeQL\"\n\non:\n push:\n branches: [main]\n pull_request:\n # The branches below must be a subset of the branch"
},
{
"path": ".gitignore",
"chars": 172,
"preview": ".project\nnode_modules\nbower_components\nnpm-debug.log\n.vscode\nyarn-error.log\nnbproject/private/private.properties\nnbproje"
},
{
"path": ".nvmrc",
"chars": 6,
"preview": "lts/*\n"
},
{
"path": ".prettierignore",
"chars": 0,
"preview": ""
},
{
"path": ".prettierrc",
"chars": 52,
"preview": "{\n \"trailingComma\": \"es5\",\n \"singleQuote\": true\n}\n"
},
{
"path": ".settings/.gitignore",
"chars": 184,
"preview": "/.jsdtscope\n/org.eclipse.ltk.core.refactoring.prefs\n/org.eclipse.wst.common.project.facet.core.xml\n/org.eclipse.wst.jsdt"
},
{
"path": "LICENSE",
"chars": 27637,
"preview": "DOMPurify\nCopyright 2025 Dr.-Ing. Mario Heiderich, Cure53\n\nDOMPurify is free software; you can redistribute it and/or mo"
},
{
"path": "README.md",
"chars": 28881,
"preview": "# DOMPurify\n\n[](http://badge.fury.io/js/dompurify)  {\n var rulesLookup = {\n 0 : 'ArrayComma',\n 1 : 'ArrayOpen',\n 2 : 'ArrayClose'"
},
{
"path": "demos/trusted-types-demo.html",
"chars": 3430,
"preview": "<!doctype html>\n<html>\n <head>\n <meta http-equiv=\"Content-Security-Policy\" content=\"trusted-types dompurify#de"
},
{
"path": "dist/purify.cjs.d.ts",
"chars": 16473,
"preview": "/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Pub"
},
{
"path": "dist/purify.cjs.js",
"chars": 64652,
"preview": "/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Pub"
},
{
"path": "dist/purify.es.d.mts",
"chars": 16439,
"preview": "/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Pub"
},
{
"path": "dist/purify.es.mjs",
"chars": 64642,
"preview": "/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Pub"
},
{
"path": "dist/purify.js",
"chars": 67741,
"preview": "/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Pub"
},
{
"path": "package.json",
"chars": 5968,
"preview": "{\n \"scripts\": {\n \"lint\": \"xo src/*.ts\",\n \"format\": \"npm run format:js && npm run format:md\",\n \"format:md\": \"pr"
},
{
"path": "rollup.config.js",
"chars": 2615,
"preview": "const fs = require('fs');\nconst { DEFAULT_EXTENSIONS } = require('@babel/core');\nconst babel = require('@rollup/plugin-b"
},
{
"path": "scripts/commit-amend-build.sh",
"chars": 273,
"preview": "echo \"# Amending minified assets to HEAD\"\n\ngit add ./dist/purify.js ./dist/purify.js.map ./dist/purify.min.js ./dist/pur"
},
{
"path": "scripts/fix-types.js",
"chars": 1385,
"preview": "// @ts-check\n\nconst fs = require('node:fs/promises');\nconst path = require('node:path');\n\n(async () => {\n // Note that "
},
{
"path": "src/attrs.ts",
"chars": 5300,
"preview": "import { freeze } from './utils.js';\n\nexport const html = freeze([\n 'accept',\n 'action',\n 'align',\n 'alt',\n 'autoca"
},
{
"path": "src/config.ts",
"chars": 7424,
"preview": "/* eslint-disable @typescript-eslint/indent */\n\nimport type { TrustedTypePolicy } from 'trusted-types/lib/index.js';\n\n/*"
},
{
"path": "src/license_header",
"chars": 192,
"preview": "/*! @license DOMPurify VERSION | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla P"
},
{
"path": "src/purify.ts",
"chars": 63081,
"preview": "/* eslint-disable @typescript-eslint/indent */\n\nimport type {\n TrustedHTML,\n TrustedTypesWindow,\n} from 'trusted-types"
},
{
"path": "src/regexp.ts",
"chars": 1054,
"preview": "import { seal } from './utils.js';\n\n// eslint-disable-next-line unicorn/better-regex\nexport const MUSTACHE_EXPR = seal(/"
},
{
"path": "src/tags.ts",
"chars": 3819,
"preview": "import { freeze } from './utils.js';\n\nexport const html = freeze([\n 'a',\n 'abbr',\n 'acronym',\n 'address',\n 'area',\n"
},
{
"path": "src/utils.ts",
"chars": 6350,
"preview": "const {\n entries,\n setPrototypeOf,\n isFrozen,\n getPrototypeOf,\n getOwnPropertyDescriptor,\n} = Object;\n\nlet { freeze"
},
{
"path": "test/bootstrap-test-suite.js",
"chars": 7012,
"preview": "const fs = require('fs');\n\nmodule.exports = function (JSDOM) {\n class StringWrapper {\n constructor(s) {\n this.s"
},
{
"path": "test/config/setup.js",
"chars": 352,
"preview": "window.alert = function () {\n window.xssed = true;\n};\n\nQUnit.assert.contains = function (actual, expected, message) {\n "
},
{
"path": "test/fixtures/expect.mjs",
"chars": 80576,
"preview": "export default [\n {\n \"title\": \"Don't remove data URIs from SVG images (see #205)\",\n \"payload\": \"<svg><image i"
},
{
"path": "test/jsdom-node-runner.js",
"chars": 477,
"preview": "/* jshint node: true, esnext: true */\n/* global QUnit */\n'use strict';\n\nglobal.QUnit = require('qunit');\n\nconst qunitTap"
},
{
"path": "test/jsdom-node.js",
"chars": 1638,
"preview": "/* jshint node: true, esnext: true */\n/* global QUnit */\n'use strict';\n\n// Test DOMPurify + jsdom using Node.js (version"
},
{
"path": "test/karma.conf.js",
"chars": 1481,
"preview": "const includePaths = require('rollup-plugin-includepaths');\nconst rollupConfig = require('../rollup.config.js')[0];\ncons"
},
{
"path": "test/karma.custom-launchers.config.js",
"chars": 5727,
"preview": "const argv = require('minimist')(process.argv.slice(2));\n\nconst customLaunchers = {\n bs_sierra_safari_10: {\n base: '"
},
{
"path": "test/purify.min.spec.js",
"chars": 287,
"preview": "import 'purify.min';\nimport './test-suite';\nimport tests from './fixtures/expect.mjs';\n\nconst xssTests = tests.filter(fu"
},
{
"path": "test/purify.spec.js",
"chars": 282,
"preview": "import 'purify';\nimport './test-suite';\nimport tests from './fixtures/expect.mjs';\n\nconst xssTests = tests.filter(functi"
},
{
"path": "test/test-suite.js",
"chars": 81858,
"preview": "(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined'\n ? (module.exports = fac"
},
{
"path": "tsconfig.json",
"chars": 218,
"preview": "{\n \"compilerOptions\": {\n \"declaration\": false,\n \"target\": \"ESNext\",\n \"module\": \"ESNext\",\n \"moduleResolution"
},
{
"path": "typescript/commonjs/index.ts",
"chars": 97,
"preview": "import * as dompurify from 'dompurify';\n\ndompurify.sanitize('<p>');\ndompurify().sanitize('<p>');\n"
},
{
"path": "typescript/commonjs/tsconfig.json",
"chars": 80,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"CommonJS\",\n \"target\": \"ES2015\"\n }\n}\n"
},
{
"path": "typescript/commonjs-with-no-types/index.ts",
"chars": 97,
"preview": "import * as dompurify from 'dompurify';\n\ndompurify.sanitize('<p>');\ndompurify().sanitize('<p>');\n"
},
{
"path": "typescript/commonjs-with-no-types/tsconfig.json",
"chars": 108,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"CommonJS\",\n \"target\": \"ES2015\",\n \"typeRoots\": [\"types\"]\n }\n}\n"
},
{
"path": "typescript/commonjs-with-no-types/types/readme.md",
"chars": 60,
"preview": "This simulates not having `@types/trusted-types` installed.\n"
},
{
"path": "typescript/commonjs-with-specific-types/index.ts",
"chars": 97,
"preview": "import * as dompurify from 'dompurify';\n\ndompurify.sanitize('<p>');\ndompurify().sanitize('<p>');\n"
},
{
"path": "typescript/commonjs-with-specific-types/tsconfig.json",
"chars": 103,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"CommonJS\",\n \"target\": \"ES2015\",\n \"types\": [\"node\"]\n }\n}\n"
},
{
"path": "typescript/esm/index.ts",
"chars": 92,
"preview": "import dompurify from 'dompurify';\n\ndompurify.sanitize('<p>');\ndompurify().sanitize('<p>');\n"
},
{
"path": "typescript/esm/package.json",
"chars": 23,
"preview": "{\n \"type\": \"module\"\n}\n"
},
{
"path": "typescript/esm/tsconfig.json",
"chars": 89,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"ES2022\",\n \"moduleResolution\": \"bundler\"\n }\n}\n"
},
{
"path": "typescript/esm-with-no-types/index.ts",
"chars": 92,
"preview": "import dompurify from 'dompurify';\n\ndompurify.sanitize('<p>');\ndompurify().sanitize('<p>');\n"
},
{
"path": "typescript/esm-with-no-types/package.json",
"chars": 23,
"preview": "{\n \"type\": \"module\"\n}\n"
},
{
"path": "typescript/esm-with-no-types/tsconfig.json",
"chars": 117,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"ES2022\",\n \"moduleResolution\": \"bundler\",\n \"typeRoots\": [\"types\"]\n }\n}\n"
},
{
"path": "typescript/esm-with-no-types/types/readme.md",
"chars": 60,
"preview": "This simulates not having `@types/trusted-types` installed.\n"
},
{
"path": "typescript/esm-with-specific-types/index.ts",
"chars": 92,
"preview": "import dompurify from 'dompurify';\n\ndompurify.sanitize('<p>');\ndompurify().sanitize('<p>');\n"
},
{
"path": "typescript/esm-with-specific-types/package.json",
"chars": 23,
"preview": "{\n \"type\": \"module\"\n}\n"
},
{
"path": "typescript/esm-with-specific-types/tsconfig.json",
"chars": 112,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"ES2022\",\n \"moduleResolution\": \"bundler\",\n \"types\": [\"node\"]\n }\n}\n"
},
{
"path": "typescript/nodenext/index.ts",
"chars": 92,
"preview": "import dompurify from 'dompurify';\n\ndompurify.sanitize('<p>');\ndompurify().sanitize('<p>');\n"
},
{
"path": "typescript/nodenext/tsconfig.json",
"chars": 92,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"NodeNext\",\n \"moduleResolution\": \"nodenext\"\n }\n}\n"
},
{
"path": "typescript/package.json",
"chars": 55,
"preview": "{\n \"dependencies\": {\n \"dompurify\": \"file:..\"\n }\n}\n"
},
{
"path": "typescript/verify.js",
"chars": 3217,
"preview": "// @ts-check\n\nconst fs = require('node:fs/promises');\nconst path = require('node:path');\nconst ts = require('typescript'"
},
{
"path": "website/index.html",
"chars": 5342,
"preview": "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title>DOMPurify 3.3.3 \"Vocalion\"</ti"
}
]
About this extraction
This page contains the full source code of the cure53/DOMPurify GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 83 files (982.4 KB), approximately 266.1k tokens, and a symbol index with 134 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.