sanitize-html 2.6.0 → 2.6.1

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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.6.1 (2021-12-08)
4
+
5
+ - Fixes style filtering to retain `!important` when used.
6
+ - Fixed trailing text bug on `transformTags` options that was reported on [issue #506](https://github.com/apostrophecms/sanitize-html/issues/506). Thanks to [Alex Rantos](https://github.com/alex-rantos).
7
+
3
8
  ## 2.6.0 (2021-11-23)
4
9
 
5
10
  - Support for regular expressions in the `allowedClasses` option. Thanks to [Alex Rantos](https://github.com/alex-rantos).
package/index.js CHANGED
@@ -582,6 +582,7 @@ function sanitizeHtml(html, options, _recursing) {
582
582
  result = tempResult + escapeHtml(result);
583
583
  tempResult = '';
584
584
  }
585
+ addedText = false;
585
586
  }
586
587
  }, options.parser);
587
588
  parser.write(html);
@@ -690,17 +691,17 @@ function sanitizeHtml(html, options, _recursing) {
690
691
  }
691
692
 
692
693
  /**
693
- * Extracts the style attribues from an AbstractSyntaxTree and formats those
694
+ * Extracts the style attributes from an AbstractSyntaxTree and formats those
694
695
  * values in the inline style attribute format.
695
696
  *
696
697
  * @param {AbstractSyntaxTree} filteredAST
697
- * @return {string} - Example: "color:yellow;text-align:center;font-family:helvetica;"
698
+ * @return {string} - Example: "color:yellow;text-align:center !important;font-family:helvetica;"
698
699
  */
699
700
  function stringifyStyleAttributes(filteredAST) {
700
701
  return filteredAST.nodes[0].nodes
701
- .reduce(function(extractedAttributes, attributeObject) {
702
+ .reduce(function(extractedAttributes, attrObject) {
702
703
  extractedAttributes.push(
703
- attributeObject.prop + ':' + attributeObject.value
704
+ `${attrObject.prop}:${attrObject.value}${attrObject.important ? ' !important' : ''}`
704
705
  );
705
706
  return extractedAttributes;
706
707
  }, [])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanitize-html",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
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",