mirror of https://github.com/curbengh/hexo-yam
test(html): invalid input
- uncovered using blns.json - https://github.com/minimaxir/big-list-of-naughty-strings
This commit is contained in:
parent
e1843f7400
commit
9e67d11e8a
|
@ -69,10 +69,14 @@ function minifyHtml (str, data) {
|
||||||
// Return if a path matches exclusion pattern
|
// Return if a path matches exclusion pattern
|
||||||
if (isMatch(path, exclude, globOptions)) return str
|
if (isMatch(path, exclude, globOptions)) return str
|
||||||
|
|
||||||
const result = Htmlminifier(str, options)
|
try {
|
||||||
if (verbose) logFn.call(this, str, result, path, 'html')
|
const result = Htmlminifier(str, options)
|
||||||
|
if (verbose) logFn.call(this, str, result, path, 'html')
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function minifyCss (str, data) {
|
async function minifyCss (str, data) {
|
||||||
|
|
|
@ -103,4 +103,12 @@ describe('html', () => {
|
||||||
|
|
||||||
expect(result).toBe(expected)
|
expect(result).toBe(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('invalid string', () => {
|
||||||
|
const invalid = '<html><>?:"{}|_+</html>'
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
h(invalid, { path })
|
||||||
|
}).toThrow('Parse Error')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue