chore(deps): remove dompurify

This commit is contained in:
Shiny Nematoda 2024-07-22 13:19:45 +00:00
parent 7b18bdd9d5
commit 8d01101331
8 changed files with 14 additions and 24 deletions

View file

@ -12,8 +12,8 @@ const { t } = useI18n(),
<template>
<TextModal>
<template #content>
<pre class="placeholder" :data-placeholder="t('info.no_info')">{{
text ? parse(text.replaceAll('<br>', '\n')) : ''
<pre class="placeholder" :data-placeholder="t('info.no_info')">{{
text && parse(text.replaceAll('<br>', '\n'))
}}</pre>
</template>
</TextModal>

View file

@ -44,9 +44,7 @@ get();
watch(
() => data.state.url,
() => {
get();
},
() => get(),
);
</script>

View file

@ -32,7 +32,10 @@ export async function getJson(url, opts) {
);
console.error(res.message);
} else if (res) return JSON.parse(useSanitize(JSON.stringify(res)));
return {};
}
return res;
}
export async function getJsonPiped(path, opts) {

View file

@ -1,4 +1,3 @@
import DOMPurify from 'dompurify';
import { useI18n } from '@/stores/misc.js';
export const AMP = /&amp;/g;
@ -6,9 +5,10 @@ export const PL_EXP =
/[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}/;
export function useSanitize(txt) {
return DOMPurify.sanitize(txt, {
ALLOWED_TAGS: ['br'],
});
return ('' + txt).replace(AMP, '&')
.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;');
}
export function useAutoTheme(t) {

View file

@ -1,3 +1,5 @@
import { useSanitize } from '@/scripts/util.js';
function useAttr(json) {
let attrs = '';
@ -28,11 +30,7 @@ function useElems(json) {
} else elems += '/>';
break;
case 'string':
elems += ('' + elem)
.replace(/&amp;/g, '&')
.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;');
elems += useSanitize(elem);
break;
}
});