Skip to content

Commit

Permalink
Restore config for removing self closing tags in attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
edg2s committed Feb 4, 2023
1 parent 90326ef commit d2f11a4
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 9 deletions.
9 changes: 8 additions & 1 deletion dist/purify.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.cjs.js.map

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/purify.es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.es.js.map

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/purify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ function createDOMPurify(window = getGlobal()) {
/* Decide if unknown protocols are okay */
let ALLOW_UNKNOWN_PROTOCOLS = false;

/* Decide if self-closing tags in attributes are allowed.
* Usually removed due to a mXSS issue in jQuery 3.0 */
let ALLOW_SELF_CLOSE_IN_ATTR = true;

/* Output should be safe for common template engines.
* This means, DOMPurify removes data attributes, mustaches and ERB
*/
Expand Down Expand Up @@ -468,6 +472,7 @@ function createDOMPurify(window = getGlobal()) {
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
RETURN_DOM = cfg.RETURN_DOM || false; // Default false
Expand Down Expand Up @@ -1190,6 +1195,7 @@ function createDOMPurify(window = getGlobal()) {
*
* @param {Node} currentNode to sanitize
*/
// eslint-disable-next-line complexity
const _sanitizeAttributes = function (currentNode) {
let attr;
let value;
Expand Down Expand Up @@ -1241,7 +1247,7 @@ function createDOMPurify(window = getGlobal()) {
}

/* Work around a security issue in jQuery 3.0 */
if (regExpTest(/\/>/i, value)) {
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
_removeAttribute(name, currentNode);
continue;
}
Expand Down

0 comments on commit d2f11a4

Please sign in to comment.