|
|
|
|
@ -72,12 +72,6 @@ export function merge_ssr_styles(style_attribute, style_directive) {
|
|
|
|
|
const ATTR_REGEX = /[&"]/g;
|
|
|
|
|
const CONTENT_REGEX = /[&<]/g;
|
|
|
|
|
|
|
|
|
|
const escapes = {
|
|
|
|
|
'"': '"',
|
|
|
|
|
'&': '&',
|
|
|
|
|
'<': '<'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function escape(html: string, is_attr = false) {
|
|
|
|
|
if (typeof html !== 'string') return html;
|
|
|
|
|
|
|
|
|
|
@ -89,7 +83,8 @@ export function escape(html: string, is_attr = false) {
|
|
|
|
|
|
|
|
|
|
while (pattern.test(html)) {
|
|
|
|
|
const i = pattern.lastIndex - 1;
|
|
|
|
|
escaped += html.slice(last, i) + escapes[html[i]];
|
|
|
|
|
const ch = html[i];
|
|
|
|
|
escaped += html.slice(last, i) + (ch === '&' ? '&' : (ch === '"' ? '"' : '<'));
|
|
|
|
|
last = i + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|