sanitize-html 2.3.2 → 2.3.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,8 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.3.3 (2021-03-19):
4
+ - Security fix: `allowedSchemes` and related options did not properly block schemes containing a hyphen, plus sign, period or digit, such as `ms-calculator:`. Thanks to Lukas Euler for pointing out the issue.
5
+ - Added a security note about the known risks associated with using the `parser` option, especially `decodeEntities: false`. See the documentation.
6
+
3
7
  ## 2.3.2 (2021-01-26):
8
+
4
9
  - Additional fixes for iframe validation exploits. Prevent exploits based on browsers' tolerance of the use of "\" rather than "/" and the presence of whitespace at this point in the URL. Thanks to Ron Masas of [Checkmarx](https://www.checkmarx.com/) for pointing out the issue and writing unit tests.
5
- - Documentation correction for `yarn` users. Thanks to Tagir Khadzhiev.
10
+ - Updates README `yarn add` syntax. Thanks to [Tagir Khadshiev](https://github.com/Aspedm) for the contribution.
6
11
 
7
12
  ## 2.3.1 (2021-01-22):
8
13
  - Uses the standard WHATWG URL parser to stop IDNA (Internationalized Domain Name) attacks on the iframe hostname validator. Thanks to Ron Masas of [Checkmarx](https://www.checkmarx.com/) for pointing out the issue and suggesting the use of the WHATWG parser.
package/README.md CHANGED
@@ -274,7 +274,9 @@ enforceHtmlBoundary: true
274
274
 
275
275
  ### htmlparser2 Options
276
276
 
277
- sanitize-html is built on `htmlparser2`. By default the only option passed down is `decodeEntities: true` You can set the options to pass by using the parser option.
277
+ sanitize-html is built on `htmlparser2`. By default the only option passed down is `decodeEntities: true`. You can set the options to pass by using the parser option.
278
+
279
+ **Security note: changing the `parser` settings can be risky.** In particular, `decodeEntities: false` has known security concerns and a complete test suite does not exist for every possible combination of settings when used with `sanitize-html`. If security is your goal we recommend you use the defaults rather than changing `parser`, except for the `lowerCaseTags` option.
278
280
 
279
281
  ```javascript
280
282
  const clean = sanitizeHtml(dirty, {
package/index.js CHANGED
@@ -568,7 +568,9 @@ function sanitizeHtml(html, options, _recursing) {
568
568
  // a javascript: URL to be snuck through
569
569
  href = href.replace(/<!--.*?-->/g, '');
570
570
  // Case insensitive so we don't get faked out by JAVASCRIPT #1
571
- const matches = href.match(/^([a-zA-Z]+):/);
571
+ // Allow more characters after the first so we don't get faked
572
+ // out by certain schemes browsers accept
573
+ const matches = href.match(/^([a-zA-Z][a-zA-Z0-9.\-+]*):/);
572
574
  if (!matches) {
573
575
  // Protocol-relative URL starting with any combination of '/' and '\'
574
576
  if (href.match(/^[/\\]{2}/)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanitize-html",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "description": "Clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis",
5
5
  "sideEffects": false,
6
6
  "main": "index.js",