sanitize-html 1.19.1 → 1.20.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 +11 -1
- package/README.md +8 -6
- package/dist/index.js +2 -2
- package/dist/sanitize-html.js +10710 -13304
- package/dist/sanitize-html.min.js +1 -12
- package/package.json +14 -11
- package/.babelrc +0 -5
- package/.travis.yml +0 -5
- package/Makefile +0 -10
- package/logos/logo-box-builtby.png +0 -0
- package/logos/logo-box-madefor.png +0 -0
- package/src/index.js +0 -610
- package/test/test.js +0 -822
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
1.20.1: Fix failing tests, add CircleCI config
|
|
4
|
+
|
|
5
|
+
1.20.0: reduced size of npm package via the `files` key; we only need to publish what's in `dist`. Thanks to Steven. There should be zero impact on behavior, minor version bump is precautionary.
|
|
6
|
+
|
|
7
|
+
1.19.3: reverted to `postcss` due to a [reported issue with `css-tree` that might or might not have XSS implications](https://github.com/punkave/sanitize-html/issues/269).
|
|
8
|
+
|
|
9
|
+
1.19.2:
|
|
10
|
+
|
|
11
|
+
* Switched out the heavy `postcss` dependency for the lightweight `css-tree` module. No API changes. Thanks to Justin Braithwaite.
|
|
12
|
+
* Various doc updates. Thanks to Pulkit Aggarwal and Cody Robertson.
|
|
13
|
+
|
|
3
14
|
1.19.1:
|
|
4
15
|
|
|
5
16
|
* `"` characters are now entity-escaped only when they appear in attribute values, reducing the verbosity of the resulting markup.
|
|
@@ -167,4 +178,3 @@ We're rocking our tests and have been working great in production for months, so
|
|
|
167
178
|
0.1.1: discard the text of script tags.
|
|
168
179
|
|
|
169
180
|
0.1.0: initial release.
|
|
170
|
-
|
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# sanitize-html
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://circleci.com/gh/punkave/sanitize-html/tree/master)
|
|
4
|
+
|
|
5
|
+
<a href="https://apostrophecms.org/"><img src="https://raw.github.com/punkave/sanitize-html/master/logos/logo-box-madefor.png" align="right" /></a>
|
|
4
6
|
|
|
5
7
|
`sanitize-html` provides a simple HTML sanitizer with a clear API.
|
|
6
8
|
|
|
@@ -110,7 +112,8 @@ allowedTags: [ 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol',
|
|
|
110
112
|
allowedAttributes: {
|
|
111
113
|
a: [ 'href', 'name', 'target' ],
|
|
112
114
|
// We don't currently allow img itself by default, but this
|
|
113
|
-
// would make sense if we did
|
|
115
|
+
// would make sense if we did. You could add srcset here,
|
|
116
|
+
// and if you do the URL is checked for safety
|
|
114
117
|
img: [ 'src' ]
|
|
115
118
|
},
|
|
116
119
|
// Lots of these won't come up by default because we don't allow them
|
|
@@ -119,8 +122,7 @@ selfClosing: [ 'img', 'br', 'hr', 'area', 'base', 'basefont', 'input', 'link', '
|
|
|
119
122
|
allowedSchemes: [ 'http', 'https', 'ftp', 'mailto' ],
|
|
120
123
|
allowedSchemesByTag: {},
|
|
121
124
|
allowedSchemesAppliedToAttributes: [ 'href', 'src', 'cite' ],
|
|
122
|
-
allowProtocolRelative: true
|
|
123
|
-
allowedIframeHostnames: ['www.youtube.com', 'player.vimeo.com']
|
|
125
|
+
allowProtocolRelative: true
|
|
124
126
|
```
|
|
125
127
|
|
|
126
128
|
#### "What if I want to allow all tags or all attributes?"
|
|
@@ -135,11 +137,11 @@ allowedAttributes: false
|
|
|
135
137
|
|
|
136
138
|
#### "What if I don't want to allow *any* tags?"
|
|
137
139
|
|
|
138
|
-
Also simple! Set
|
|
140
|
+
Also simple! Set `allowedTags` to `[]` and `allowedAttributes` to `{}`.
|
|
139
141
|
|
|
140
142
|
```js
|
|
141
143
|
allowedTags: [],
|
|
142
|
-
allowedAttributes:
|
|
144
|
+
allowedAttributes: {}
|
|
143
145
|
```
|
|
144
146
|
|
|
145
147
|
### "What if I want to allow only specific values on some attributes?"
|
package/dist/index.js
CHANGED
|
@@ -547,9 +547,9 @@ function sanitizeHtml(html, options, _recursing) {
|
|
|
547
547
|
*/
|
|
548
548
|
function stringifyStyleAttributes(filteredAST) {
|
|
549
549
|
return filteredAST.nodes[0].nodes.reduce(function (extractedAttributes, attributeObject) {
|
|
550
|
-
extractedAttributes.push(attributeObject.prop + ':' + attributeObject.value
|
|
550
|
+
extractedAttributes.push(attributeObject.prop + ':' + attributeObject.value);
|
|
551
551
|
return extractedAttributes;
|
|
552
|
-
}, []).join('');
|
|
552
|
+
}, []).join(';');
|
|
553
553
|
}
|
|
554
554
|
|
|
555
555
|
/**
|