mirror of
https://codeberg.org/Hyperpipe/Hyperpipe
synced 2025-06-28 05:08:00 +02:00
chore(deps): remove dompurify
This commit is contained in:
parent
7b18bdd9d5
commit
8d01101331
8 changed files with 14 additions and 24 deletions
|
@ -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>
|
||||
|
|
|
@ -44,9 +44,7 @@ get();
|
|||
|
||||
watch(
|
||||
() => data.state.url,
|
||||
() => {
|
||||
get();
|
||||
},
|
||||
() => get(),
|
||||
);
|
||||
</script>
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import DOMPurify from 'dompurify';
|
||||
import { useI18n } from '@/stores/misc.js';
|
||||
|
||||
export const 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, '&')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/</g, '<');
|
||||
}
|
||||
|
||||
export function useAutoTheme(t) {
|
||||
|
|
|
@ -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(/&/g, '&')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/</g, '<');
|
||||
elems += useSanitize(elem);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue