Skip to content

Commit 2719515

Browse files
committed
fix: throw TypeError if 'html' is non-string argument
1 parent 27a5dd9 commit 2719515

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"main": "src/striptags.js",
1111
"homepage": "https://github.com/ericnorris/striptags",
1212
"bugs": "https://github.com/ericnorris/striptags/issues",
13-
"version": "3.1.1",
13+
"version": "3.2.0",
1414
"devDependencies": {
1515
"istanbul": "^0.4.5",
1616
"mocha": "^3.2.0"

src/striptags.js

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
}
5757

5858
function striptags_internal(html, context) {
59+
if (typeof html != "string") {
60+
throw new TypeError("'html' parameter must be a string");
61+
}
62+
5963
let allowable_tags = context.allowable_tags;
6064
let tag_replacement = context.tag_replacement;
6165

test/striptags-test.js

+9
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,13 @@ describe('striptags', function() {
157157
assert.equal(part_three, '< amet');
158158
});
159159
});
160+
161+
it('GHSL-2021-074', function() {
162+
assert.throws(
163+
function() {
164+
striptags(["type-confusion"]);
165+
},
166+
TypeError,
167+
);
168+
});
160169
});

0 commit comments

Comments
 (0)