Skip to content

Commit

Permalink
Merge pull request from GHSA-qxg5-2qff-p49r
Browse files Browse the repository at this point in the history
fix: throw TypeError if 'html' is non-string argument
  • Loading branch information
ericnorris authored Jun 18, 2021
2 parents 27a5dd9 + 2719515 commit f252a6b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"main": "src/striptags.js",
"homepage": "https://github.com/ericnorris/striptags",
"bugs": "https://github.com/ericnorris/striptags/issues",
"version": "3.1.1",
"version": "3.2.0",
"devDependencies": {
"istanbul": "^0.4.5",
"mocha": "^3.2.0"
Expand Down
4 changes: 4 additions & 0 deletions src/striptags.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
}

function striptags_internal(html, context) {
if (typeof html != "string") {
throw new TypeError("'html' parameter must be a string");
}

let allowable_tags = context.allowable_tags;
let tag_replacement = context.tag_replacement;

Expand Down
9 changes: 9 additions & 0 deletions test/striptags-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,13 @@ describe('striptags', function() {
assert.equal(part_three, '< amet');
});
});

it('GHSL-2021-074', function() {
assert.throws(
function() {
striptags(["type-confusion"]);
},
TypeError,
);
});
});

0 comments on commit f252a6b

Please sign in to comment.