sanitize-html 2.6.1 → 2.7.0

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.7.0 (2022-02-04)
4
+
5
+ - Allows a more sensible set of default attributes on `<img />` tags. Thanks to [Zade Viggers](https://github.com/zadeviggers).
6
+
3
7
  ## 2.6.1 (2021-12-08)
4
8
 
5
9
  - Fixes style filtering to retain `!important` when used.
package/README.md CHANGED
@@ -128,10 +128,9 @@ allowedTags: [
128
128
  disallowedTagsMode: 'discard',
129
129
  allowedAttributes: {
130
130
  a: [ 'href', 'name', 'target' ],
131
- // We don't currently allow img itself by default, but this
132
- // would make sense if we did. You could add srcset here,
133
- // and if you do the URL is checked for safety
134
- img: [ 'src' ]
131
+ // We don't currently allow img itself by default, but
132
+ // these attributes would make sense if we did.
133
+ img: [ 'src', 'srcset', 'alt', 'title', 'width', 'height', 'loading' ]
135
134
  },
136
135
  // Lots of these won't come up by default because we don't allow them
137
136
  selfClosing: [ 'img', 'br', 'hr', 'area', 'base', 'basefont', 'input', 'link', 'meta' ],
package/index.js CHANGED
@@ -780,10 +780,9 @@ sanitizeHtml.defaults = {
780
780
  disallowedTagsMode: 'discard',
781
781
  allowedAttributes: {
782
782
  a: [ 'href', 'name', 'target' ],
783
- // We don't currently allow img itself by default, but this
784
- // would make sense if we did. You could add srcset here,
785
- // and if you do the URL is checked for safety
786
- img: [ 'src' ]
783
+ // We don't currently allow img itself by default, but
784
+ // these attributes would make sense if we did.
785
+ img: [ 'src', 'srcset', 'alt', 'title', 'width', 'height', 'loading' ]
787
786
  },
788
787
  // Lots of these won't come up by default because we don't allow them
789
788
  selfClosing: [ 'img', 'br', 'hr', 'area', 'base', 'basefont', 'input', 'link', 'meta' ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanitize-html",
3
- "version": "2.6.1",
3
+ "version": "2.7.0",
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",