feat(parser): automatically escape attributes in template strings

This commit is contained in:
teidesu 2022-06-05 23:53:59 +03:00
parent 1cce5c79a2
commit cd88a3a74a

View file

@ -26,8 +26,12 @@ export function html(
sub.forEach((it, idx) => {
if (typeof it === 'boolean' || !it) return
if (typeof it === 'string') it = HtmlMessageEntityParser.escape(it)
else {
if (typeof it === 'string') {
it = HtmlMessageEntityParser.escape(
it,
!!str.match(/=['"]$/)
)
} else {
if (it.mode && it.mode !== 'html')
throw new Error(`Incompatible parse mode: ${it.mode}`)
it = it.value