TODO: fix possible mitm in icon.svelte

split writes "Worst Svelte Component Ever", asked to leave Etcetera
This commit is contained in:
May 2023-10-16 18:56:26 +00:00
parent 707dbeb559
commit d7698100d1

View file

@ -0,0 +1,26 @@
<script context="module">
let iconCache = new Map()
</script>
<script>
export let icon; // like "admin/___"
let iconSrc;
if (iconCache.has(icon)) {
iconSrc = iconCache.get(icon)
} else {
fetch(`/static/assets/icons/${icon}`).then((response) => {
if (response.ok) response.text().then(src => {
iconCache.set( icon, src )
iconSrc = src
})
})
}
</script>
<div class="iconContainer">
{@html iconSrc} <!-- TODO: !! MITM attack very possible here so we'll need to purify this later! -->
</div>