Skip to content

Commit 4083a90

Browse files
authored
Merge pull request #978 from cure53/main
Getting 3.x branch ready for 3.1.6 release
2 parents 6676133 + 90a10a1 commit 4083a90

17 files changed

+221
-157
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
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.1.5**.
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.1.6**.
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

13-
**Note that [DOMPurify v2.5.5](https://github.com/cure53/DOMPurify/releases/tag/2.5.5) 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).**
13+
**Note that [DOMPurify v2.5.6](https://github.com/cure53/DOMPurify/releases/tag/2.5.6) 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).**
1414

1515
Our automated tests cover [19 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 v16.x, v17.x, v18.x and v19.x, running DOMPurify on [jsdom](https://github.com/jsdom/jsdom). Older Node versions are known to work as well, but hey... no guarantees.
1616

@@ -181,6 +181,9 @@ const clean = DOMPurify.sanitize(dirty, {SAFE_FOR_TEMPLATES: true});
181181

182182

183183
// change how e.g. comments containing risky HTML characters are treated.
184+
// be very careful, this setting should only be set to `false` if you really only handle
185+
// HTML and nothing else, no SVG, MathML or the like.
186+
// Otherwise, changing from `true` to `false` will lead to XSS in this or some other way.
184187
const clean = DOMPurify.sanitize(dirty, {SAFE_FOR_XML: false});
185188
```
186189

@@ -378,6 +381,12 @@ DOMPurify.addHook(
378381
);
379382
```
380383
384+
## Removed Configuration
385+
386+
| Option | Since | Note |
387+
|-----------------|-------|--------------------------|
388+
| SAFE_FOR_JQUERY | 2.1.0 | No replacement required. |
389+
381390
## Continuous Integration
382391
383392
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

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dompurify",
3-
"version": "3.1.5",
3+
"version": "3.1.6",
44
"homepage": "https://github.com/cure53/DOMPurify",
55
"author": "Cure53 <[email protected]>",
66
"description": "A DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG",

dist/purify.cjs.js

Lines changed: 13 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/purify.cjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/purify.es.mjs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! @license DOMPurify 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */
1+
/*! @license DOMPurify 3.1.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.1.6/LICENSE */
22

33
const {
44
entries,
@@ -209,11 +209,9 @@ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-
209209
const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
210210
const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
211211
);
212-
213212
const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
214213
const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
215214
);
216-
217215
const DOCTYPE_NAME = seal(/^html$/i);
218216
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
219217

@@ -248,7 +246,6 @@ const NODE_TYPE = {
248246
documentFragment: 11,
249247
notation: 12 // Deprecated
250248
};
251-
252249
const getGlobal = function getGlobal() {
253250
return typeof window === 'undefined' ? null : window;
254251
};
@@ -300,7 +297,7 @@ function createDOMPurify() {
300297
* Version label, exposed for easier checks
301298
* if DOMPurify is up to date or not
302299
*/
303-
DOMPurify.version = '3.1.5';
300+
DOMPurify.version = '3.1.6';
304301

305302
/**
306303
* Array of elements that DOMPurify removed during sanitation.
@@ -331,6 +328,7 @@ function createDOMPurify() {
331328
} = window;
332329
const ElementPrototype = Element.prototype;
333330
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
331+
const remove = lookupGetter(ElementPrototype, 'remove');
334332
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
335333
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
336334
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
@@ -831,9 +829,9 @@ function createDOMPurify() {
831829
});
832830
try {
833831
// eslint-disable-next-line unicorn/prefer-dom-node-remove
834-
node.parentNode.removeChild(node);
832+
getParentNode(node).removeChild(node);
835833
} catch (_) {
836-
node.remove();
834+
remove(node);
837835
}
838836
};
839837

@@ -1010,7 +1008,7 @@ function createDOMPurify() {
10101008
return true;
10111009
}
10121010

1013-
/* Remove any ocurrence of processing instructions */
1011+
/* Remove any occurrence of processing instructions */
10141012
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
10151013
_forceRemove(currentNode);
10161014
return true;
@@ -1179,6 +1177,13 @@ function createDOMPurify() {
11791177
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
11801178
_executeHook('uponSanitizeAttribute', currentNode, hookEvent);
11811179
value = hookEvent.attrValue;
1180+
1181+
/* Work around a security issue with comments inside attributes */
1182+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
1183+
_removeAttribute(name, currentNode);
1184+
continue;
1185+
}
1186+
11821187
/* Did the hooks approve of the attribute? */
11831188
if (hookEvent.forceKeepAttr) {
11841189
continue;
@@ -1198,12 +1203,6 @@ function createDOMPurify() {
11981203
continue;
11991204
}
12001205

1201-
/* Work around a security issue with comments inside attributes */
1202-
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
1203-
_removeAttribute(name, currentNode);
1204-
continue;
1205-
}
1206-
12071206
/* Sanitize attribute content to be template-safe */
12081207
if (SAFE_FOR_TEMPLATES) {
12091208
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {

dist/purify.es.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/purify.js

Lines changed: 13 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/purify.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/purify.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/purify.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)