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

@ -123,7 +123,6 @@ You can reach out to me personally on:
- ViteJS -> [MIT][vite] - ViteJS -> [MIT][vite]
- shaka-player -> [Apache-2.0][shaka] - shaka-player -> [Apache-2.0][shaka]
- PeerJS -> [MIT][peer] - PeerJS -> [MIT][peer]
- DOMPurify -> [Apache-2.0][purify]
- SortableJS -> [MIT][sortable] - SortableJS -> [MIT][sortable]
- Bootstrap Icons -> [MIT][bi] - Bootstrap Icons -> [MIT][bi]
- VueJS theme -> [MIT][vuetheme] - VueJS theme -> [MIT][vuetheme]
@ -151,7 +150,6 @@ You can reach out to me personally on:
[bi]: https://github.com/twbs/icons/blob/main/LICENSE.md [bi]: https://github.com/twbs/icons/blob/main/LICENSE.md
[peer]: https://github.com/peers/peerjs/blob/master/LICENSE [peer]: https://github.com/peers/peerjs/blob/master/LICENSE
[shaka]: https://github.com/shaka-project/shaka-player/blob/main/LICENSE [shaka]: https://github.com/shaka-project/shaka-player/blob/main/LICENSE
[purify]: https://github.com/cure53/DOMPurify/blob/main/LICENSE
[sortable]: https://github.com/SortableJS/Sortable/blob/master/LICENSE [sortable]: https://github.com/SortableJS/Sortable/blob/master/LICENSE
[nord]: https://github.com/arcticicestudio/nord/blob/develop/LICENSE.md [nord]: https://github.com/arcticicestudio/nord/blob/develop/LICENSE.md
[vuetheme]: https://github.com/vuejs/theme/blob/main/LICENSE [vuetheme]: https://github.com/vuejs/theme/blob/main/LICENSE

6
package-lock.json generated
View file

@ -9,7 +9,6 @@
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"bootstrap-icons": "^1.11.3", "bootstrap-icons": "^1.11.3",
"dompurify": "^3.1.6",
"peerjs": "^1.5.4", "peerjs": "^1.5.4",
"pinia": "^2.1.7", "pinia": "^2.1.7",
"shaka-player": "^4.10.5", "shaka-player": "^4.10.5",
@ -3097,11 +3096,6 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/dompurify": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.1.6.tgz",
"integrity": "sha512-cTOAhc36AalkjtBpfG6O8JimdTMWNXjiePT2xQH/ppBGi/4uIpmj8eKyIkMJErXWARyINV/sB38yf8JCLF5pbQ=="
},
"node_modules/ejs": { "node_modules/ejs": {
"version": "3.1.10", "version": "3.1.10",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",

View file

@ -11,7 +11,6 @@
}, },
"dependencies": { "dependencies": {
"bootstrap-icons": "^1.11.3", "bootstrap-icons": "^1.11.3",
"dompurify": "^3.1.6",
"peerjs": "^1.5.4", "peerjs": "^1.5.4",
"pinia": "^2.1.7", "pinia": "^2.1.7",
"shaka-player": "^4.10.5", "shaka-player": "^4.10.5",

View file

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

View file

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

View file

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

View file

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

View file

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