Preserve literal text when wrapping sanitized mail markup
This commit is contained in:
parent
c72c72e41e
commit
662fec078c
@ -157,7 +157,9 @@ export function mailHtml(html, { resolveImage = safeImageUrl } = {}) {
|
|||||||
)
|
)
|
||||||
.join('')
|
.join('')
|
||||||
const shell = sanitizeHtml(`<div${serialized}></div>`, options)
|
const shell = sanitizeHtml(`<div${serialized}></div>`, options)
|
||||||
return shell.replace(/^<div/, `<div data-mail-${kind}`).replace('</div>', content + '</div>')
|
return shell
|
||||||
|
.replace(/^<div/, `<div data-mail-${kind}`)
|
||||||
|
.replace('</div>', () => content + '</div>')
|
||||||
}
|
}
|
||||||
const styled = sheets
|
const styled = sheets
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
|||||||
@ -13,6 +13,11 @@ const fixture = (name) => readFileSync(new URL('./fixtures/' + name, import.meta
|
|||||||
const png =
|
const png =
|
||||||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+a3ioAAAAASUVORK5CYII='
|
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+a3ioAAAAASUVORK5CYII='
|
||||||
|
|
||||||
|
test('Mail text containing literal dollar replacement sequences is preserved', () => {
|
||||||
|
const clean = mailHtml('<p>Code: $& $$ $`</p>')
|
||||||
|
assert(clean.includes('<p>Code: $& $$ $`</p>'))
|
||||||
|
})
|
||||||
|
|
||||||
test('Newsletter rendering preserves stylesheets, responsive rules, hidden preheaders, table geometry and source order', () => {
|
test('Newsletter rendering preserves stylesheets, responsive rules, hidden preheaders, table geometry and source order', () => {
|
||||||
const clean = mailHtml(fixture('mail-newsletter.html'))
|
const clean = mailHtml(fixture('mail-newsletter.html'))
|
||||||
assert.match(clean, /<style>/)
|
assert.match(clean, /<style>/)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user