Skip to content

Commit

Permalink
Merge pull request #557 from apostrophecms/release-2.7.1
Browse files Browse the repository at this point in the history
Release 2.7.1
  • Loading branch information
boutell committed Jul 20, 2022
2 parents 994f962 + b6c4971 commit b4682c1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
@@ -1,6 +1,9 @@
# Changelog

- Protocol-relative URLs are properly supported for script tags
## 2.7.1 (2022-07-20)

- Protocol-relative URLs are properly supported for script tags. Thanks to [paweljq](https://github.com/paweljq).
- A denial-of-service vulnerability has been fixed by replacing global regular expression replacement logic for comment removal with a new implementation. Thanks to Nariyoshi Chida of NTT Security Japan for pointing out the issue.

## 2.7.0 (2022-02-04)

Expand Down
12 changes: 11 additions & 1 deletion index.js
Expand Up @@ -612,7 +612,17 @@ function sanitizeHtml(html, options, _recursing) {
// Clobber any comments in URLs, which the browser might
// interpret inside an XML data island, allowing
// a javascript: URL to be snuck through
href = href.replace(/<!--.*?-->/g, '');
while (true) {
const firstIndex = href.indexOf('<!--');
if (firstIndex === -1) {
break;
}
const lastIndex = href.indexOf('-->', firstIndex + 4);
if (lastIndex === -1) {
break;
}
href = href.substring(0, firstIndex) + href.substring(lastIndex + 3);
}
// Case insensitive so we don't get faked out by JAVASCRIPT #1
// Allow more characters after the first so we don't get faked
// out by certain schemes browsers accept
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "sanitize-html",
"version": "2.7.0",
"version": "2.7.1",
"description": "Clean up user-submitted HTML, preserving allowlisted elements and allowlisted attributes on a per-element basis",
"sideEffects": false,
"main": "index.js",
Expand Down

0 comments on commit b4682c1

Please sign in to comment.