sanitize-html 2.5.2 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.5.3 (2021-11-02):
4
+
5
+ - Fixed bug introduced by klona 2.0.5, by removing klona entirely.
6
+
3
7
  ## 2.5.2 (2021-10-13):
4
8
 
5
9
  - Nullish HTML input now returns an empty string. Nullish value may be explicit `null`, `undefined` or implicit `undefined` when value is not provided. Thanks to Artem Kostiuk for the contribution.
package/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  const htmlparser = require('htmlparser2');
2
2
  const escapeStringRegexp = require('escape-string-regexp');
3
- const { klona } = require('klona');
4
3
  const { isPlainObject } = require('is-plain-object');
5
4
  const deepmerge = require('deepmerge');
6
5
  const parseSrcset = require('parse-srcset');
@@ -650,18 +649,18 @@ function sanitizeHtml(html, options, _recursing) {
650
649
 
651
650
  /**
652
651
  * Filters user input css properties by allowlisted regex attributes.
652
+ * Modifies the abstractSyntaxTree object.
653
653
  *
654
654
  * @param {object} abstractSyntaxTree - Object representation of CSS attributes.
655
655
  * @property {array[Declaration]} abstractSyntaxTree.nodes[0] - Each object cointains prop and value key, i.e { prop: 'color', value: 'red' }.
656
656
  * @param {object} allowedStyles - Keys are properties (i.e color), value is list of permitted regex rules (i.e /green/i).
657
- * @return {object} - Abstract Syntax Tree with filtered style attributes.
657
+ * @return {object} - The modified tree.
658
658
  */
659
659
  function filterCss(abstractSyntaxTree, allowedStyles) {
660
660
  if (!allowedStyles) {
661
661
  return abstractSyntaxTree;
662
662
  }
663
663
 
664
- const filteredAST = klona(abstractSyntaxTree);
665
664
  const astRules = abstractSyntaxTree.nodes[0];
666
665
  let selectedRule;
667
666
 
@@ -676,10 +675,10 @@ function sanitizeHtml(html, options, _recursing) {
676
675
  }
677
676
 
678
677
  if (selectedRule) {
679
- filteredAST.nodes[0].nodes = astRules.nodes.reduce(filterDeclarations(selectedRule), []);
678
+ abstractSyntaxTree.nodes[0].nodes = astRules.nodes.reduce(filterDeclarations(selectedRule), []);
680
679
  }
681
680
 
682
- return filteredAST;
681
+ return abstractSyntaxTree;
683
682
  }
684
683
 
685
684
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanitize-html",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Clean up user-submitted HTML, preserving allowlisted elements and allowlisted attributes on a per-element basis",
5
5
  "sideEffects": false,
6
6
  "main": "index.js",
@@ -27,15 +27,14 @@
27
27
  "escape-string-regexp": "^4.0.0",
28
28
  "htmlparser2": "^6.0.0",
29
29
  "is-plain-object": "^5.0.0",
30
- "klona": "^2.0.3",
31
30
  "parse-srcset": "^1.0.2",
32
- "postcss": "^8.0.2"
31
+ "postcss": "^8.3.11"
33
32
  },
34
33
  "devDependencies": {
35
34
  "eslint": "^7.3.1",
36
35
  "eslint-config-apostrophe": "^3.4.0",
37
36
  "eslint-config-standard": "^14.1.1",
38
- "eslint-plugin-import": "^2.21.2",
37
+ "eslint-plugin-import": "^2.25.2",
39
38
  "eslint-plugin-node": "^11.1.0",
40
39
  "eslint-plugin-promise": "^4.2.1",
41
40
  "eslint-plugin-standard": "^4.0.1",