Skip to content

Commit

Permalink
fix: throw TypeError if 'html' is non-string argument
Browse files Browse the repository at this point in the history
  • Loading branch information
ericnorris committed Jun 10, 2021
1 parent 27a5dd9 commit 2719515
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 2719515

Please sign in to comment.