test(html): invalid input

- uncovered using blns.json
- https://github.com/minimaxir/big-list-of-naughty-strings
This commit is contained in:
MDLeom 2020-05-25 09:13:15 +01:00
parent e1843f7400
commit 9e67d11e8a
No known key found for this signature in database
GPG Key ID: 21EA847C35D6E034
2 changed files with 15 additions and 3 deletions

View File

@ -69,10 +69,14 @@ function minifyHtml (str, data) {
// Return if a path matches exclusion pattern
if (isMatch(path, exclude, globOptions)) return str
try {
const result = Htmlminifier(str, options)
if (verbose) logFn.call(this, str, result, path, 'html')
return result
} catch (err) {
throw new Error(err)
}
}
async function minifyCss (str, data) {

View File

@ -103,4 +103,12 @@ describe('html', () => {
expect(result).toBe(expected)
})
test('invalid string', () => {
const invalid = '<html><>?:"{}|_+</html>'
expect(() => {
h(invalid, { path })
}).toThrow('Parse Error')
})
})