Skip to content

Commit aa2c561

Browse files
authoredJan 3, 2024
Merge pull request #893 from cure53/main
Getting 3.x branch ready for 3.0.7 release
2 parents db73dd7 + ab2c081 commit aa2c561

18 files changed

+156
-29
lines changed
 

‎.github/workflows/build-and-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
strategy:
1919
matrix:
20-
node-version: [16.x, 17.x, 18.x, 19.x]
20+
node-version: [16.x, 17.x, 18.x, 19.x, 20.x, 21.x]
2121

2222
steps:
2323
- name: Checkout
@@ -38,7 +38,7 @@ jobs:
3838
with:
3939
run: npm run test:ci
4040
env:
41-
TEST_BROWSERSTACK: ${{ startsWith(matrix.node-version, '19') }}
41+
TEST_BROWSERSTACK: ${{ startsWith(matrix.node-version, '21') }}
4242
TEST_PROBE_ONLY: ${{ github.ref != 'refs/heads/main' }}
4343
BS_USERNAME: ${{ secrets.BS_USERNAME }}
4444
BS_ACCESSKEY: ${{ secrets.BS_ACCESSKEY }}

‎.github/workflows/codeql-analysis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ jobs:
3838

3939
# Initializes the CodeQL tools for scanning.
4040
- name: Initialize CodeQL
41-
uses: github/codeql-action/init@v2
41+
uses: github/codeql-action/init@v3
4242
with:
4343
languages: ${{ matrix.language }}
4444

4545
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
4646
# If this step fails, then you should remove it and run the build manually (see below)
4747
- name: Autobuild
48-
uses: github/codeql-action/autobuild@v2
48+
uses: github/codeql-action/autobuild@v3
4949

5050
# ℹ️ Command-line programs to run using the OS shell.
5151
# 📚 https://git.io/JvXDl
@@ -59,4 +59,4 @@ jobs:
5959
# make release
6060

6161
- name: Perform CodeQL Analysis
62-
uses: github/codeql-action/analyze@v2
62+
uses: github/codeql-action/analyze@v3

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG.
88

9-
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.0.6**.
9+
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.0.7**.
1010

1111
DOMPurify is written in 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.
1212

‎bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "DOMPurify",
3-
"version": "3.0.6",
3+
"version": "3.0.7",
44
"homepage": "https://github.com/cure53/DOMPurify",
55
"author": "Cure53 <info@cure53.de>",
66
"description": "A DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG",

‎dist/purify.cjs.js

+24-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.es.mjs

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! @license DOMPurify 3.0.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.6/LICENSE */
1+
/*! @license DOMPurify 3.0.7 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.7/LICENSE */
22

33
const {
44
entries,
@@ -112,6 +112,21 @@ function addToSet(set, array) {
112112
return set;
113113
}
114114

115+
/**
116+
* Clean up an array to harden against CSPP
117+
*
118+
* @param {Array} array - The array to be cleaned.
119+
* @returns {Array} The cleaned version of the array
120+
*/
121+
function cleanArray(array) {
122+
for (let index = 0; index < array.length; index++) {
123+
if (getOwnPropertyDescriptor(array, index) === undefined) {
124+
array[index] = null;
125+
}
126+
}
127+
return array;
128+
}
129+
115130
/**
116131
* Shallow clone an object
117132
*
@@ -122,7 +137,13 @@ function clone(object) {
122137
const newObject = create(null);
123138
for (const [property, value] of entries(object)) {
124139
if (getOwnPropertyDescriptor(object, property) !== undefined) {
125-
newObject[property] = value;
140+
if (Array.isArray(value)) {
141+
newObject[property] = cleanArray(value);
142+
} else if (typeof value === 'object' && value.constructor === Object) {
143+
newObject[property] = clone(value);
144+
} else {
145+
newObject[property] = value;
146+
}
126147
}
127148
}
128149
return newObject;
@@ -257,7 +278,7 @@ function createDOMPurify() {
257278
* Version label, exposed for easier checks
258279
* if DOMPurify is up to date or not
259280
*/
260-
DOMPurify.version = '3.0.6';
281+
DOMPurify.version = '3.0.7';
261282

262283
/**
263284
* Array of elements that DOMPurify removed during sanitation.

‎dist/purify.es.mjs.map

+1-1
Large diffs are not rendered by default.

‎dist/purify.js

+24-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
},
106106
"name": "dompurify",
107107
"description": "DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. It's written in JavaScript and works in all modern browsers (Safari, Opera (15+), Internet Explorer (10+), Firefox and Chrome - as well as almost anything else using Blink or WebKit). DOMPurify is written by security people who have vast background in web attacks and XSS. Fear not.",
108-
"version": "3.0.6",
108+
"version": "3.0.7",
109109
"directories": {
110110
"test": "test"
111111
},

‎src/purify.js

+1
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ function createDOMPurify(window = getGlobal()) {
784784
*/
785785
const _forceRemove = function (node) {
786786
arrayPush(DOMPurify.removed, { element: node });
787+
787788
try {
788789
// eslint-disable-next-line unicorn/prefer-dom-node-remove
789790
node.parentNode.removeChild(node);

‎src/utils.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,40 @@ function addToSet(set, array, transformCaseFunc = stringToLowerCase) {
107107
return set;
108108
}
109109

110+
/**
111+
* Clean up an array to harden against CSPP
112+
*
113+
* @param {Array} array - The array to be cleaned.
114+
* @returns {Array} The cleaned version of the array
115+
*/
116+
function cleanArray(array) {
117+
for (let index = 0; index < array.length; index++) {
118+
if (getOwnPropertyDescriptor(array, index) === undefined) {
119+
array[index] = null;
120+
}
121+
}
122+
123+
return array;
124+
}
125+
110126
/**
111127
* Shallow clone an object
112128
*
113129
* @param {Object} object - The object to be cloned.
114130
* @returns {Object} A new object that copies the original.
115131
*/
116-
export function clone(object) {
132+
function clone(object) {
117133
const newObject = create(null);
118134

119135
for (const [property, value] of entries(object)) {
120136
if (getOwnPropertyDescriptor(object, property) !== undefined) {
121-
newObject[property] = value;
137+
if (Array.isArray(value)) {
138+
newObject[property] = cleanArray(value);
139+
} else if (typeof value === 'object' && value.constructor === Object) {
140+
newObject[property] = clone(value);
141+
} else {
142+
newObject[property] = value;
143+
}
122144
}
123145
}
124146

@@ -172,6 +194,7 @@ export {
172194
isFrozen,
173195
setPrototypeOf,
174196
seal,
197+
clone,
175198
create,
176199
// RegExp
177200
regExpTest,

‎test/karma.custom-launchers.config.js

+40
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,30 @@ const customLaunchers = {
4242
browser: 'safari',
4343
os_version: 'Big Sur',
4444
},
45+
bs_monterey_safari_15: {
46+
base: 'BrowserStack',
47+
device: null,
48+
os: 'OS X',
49+
browser_version: '15.6',
50+
browser: 'safari',
51+
os_version: 'Monterey',
52+
},
53+
bs_ventura_safari_16: {
54+
base: 'BrowserStack',
55+
device: null,
56+
os: 'OS X',
57+
browser_version: '16.5',
58+
browser: 'safari',
59+
os_version: 'Ventura',
60+
},
61+
bs_sonoma_safari_17: {
62+
base: 'BrowserStack',
63+
device: null,
64+
os: 'OS X',
65+
browser_version: '17.0',
66+
browser: 'safari',
67+
os_version: 'Sonoma',
68+
},
4569
bs_win10_edge_84: {
4670
base: 'BrowserStack',
4771
device: null,
@@ -98,6 +122,14 @@ const customLaunchers = {
98122
browser: 'firefox',
99123
os_version: '10',
100124
},
125+
bs_win10_firefox_120: {
126+
base: 'BrowserStack',
127+
device: null,
128+
os: 'Windows',
129+
browser_version: '120.0',
130+
browser: 'firefox',
131+
os_version: '11',
132+
},
101133
bs_win10_chrome_60: {
102134
base: 'BrowserStack',
103135
device: null,
@@ -146,6 +178,14 @@ const customLaunchers = {
146178
browser: 'chrome',
147179
os_version: '10',
148180
},
181+
bs_win10_chrome_120: {
182+
base: 'BrowserStack',
183+
device: null,
184+
os: 'Windows',
185+
browser_version: '120.0',
186+
browser: 'chrome',
187+
os_version: '11',
188+
},
149189
};
150190

151191
const getAllBrowsers = () => Object.keys(customLaunchers);

‎website/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="UTF-8">
5-
<title>DOMPurify 3.0.6 "Factory Reset"</title>
5+
<title>DOMPurify 3.0.7 "High Noon"</title>
66
<script src="../dist/purify.min.js"></script>
77
<!-- we don't actually need it - just to demo and test the $(html) sanitation -->
88
<script src="//code.jquery.com/jquery-3.2.0.min.js"></script>
@@ -23,7 +23,7 @@
2323
</script>
2424
</head>
2525
<body>
26-
<h4>DOMPurify 3.0.6 "Factory Reset"</h4>
26+
<h4>DOMPurify 3.0.7 "High Noon"</h4>
2727
<p>
2828
<a href="http://badge.fury.io/js/dompurify" rel="nofollow"><img alt="npm version" src="https://badge.fury.io/js/dompurify.svg"></a>
2929
<a target="_blank" rel="noopener noreferrer" href="https://github.com/cure53/DOMPurify/workflows/Build%20and%20Test/badge.svg?branch=main"><img src="https://github.com/cure53/DOMPurify/workflows/Build%20and%20Test/badge.svg?branch=main" alt="Build and Test"></a>

0 commit comments

Comments
 (0)
Please sign in to comment.