hotfix: Fix major XSS vulnerability

This commit is contained in:
Xyphyn committed 2023-07-10 09:12:38 -07:00
1 parent 4412169602
commit d34e58d809
11 files changed
+111 -101

No files matched your search

@@ -67,14 +67,16 @@
<svelte:self {post} nodes={node.children} isParent={false} />
{/if}
{#if node.comment_view.counts.child_count > 0 && node.children.length == 0}
<Button
loading={loadingChildren}
disabled={loadingChildren}
on:click={() => fetchChildren(node)}
>
<Icon src={ChevronDown} width={16} mini />
Load {node.comment_view.counts.child_count} more
</Button>
<div class="m-1">
<Button
loading={loadingChildren}
disabled={loadingChildren}
on:click={() => fetchChildren(node)}
>
<Icon src={ChevronDown} width={16} mini />
Load {node.comment_view.counts.child_count} more
</Button>
</div>
{/if}
</Comment>
{/each}
+44 -21
View File
@@ -1,25 +1,48 @@
<script lang="ts">
import MarkdownHeader from '$lib/components/markdown/MarkdownHeader.svelte'
import MarkdownHr from '$lib/components/markdown/MarkdownHr.svelte'
import MarkdownLink from '$lib/components/markdown/MarkdownLink.svelte'
import MarkdownQuote from '$lib/components/markdown/MarkdownQuote.svelte'
import SvelteMarkdown from 'svelte-markdown'
import MarkdownList from '$lib/components/markdown/MarkdownList.svelte'
import MarkdownImage from '$lib/components/markdown/MarkdownImage.svelte'
import MarkdownIt from 'markdown-it'
const md = new MarkdownIt({
html: false,
})
export let source: string | undefined
export let source: string = ''
</script>
<div class="break-words flex flex-col gap-2">
<SvelteMarkdown
{source}
renderers={{
link: MarkdownLink,
heading: MarkdownHeader,
hr: MarkdownHr,
blockquote: MarkdownQuote,
list: MarkdownList,
image: MarkdownImage,
}}
/>
</div>
<article class="break-words flex flex-col gap-2 markdown">
{@html md.render(source)}
</article>
<style lang="postcss">
.markdown :global(h1) {
@apply text-3xl font-bold my-2;
}
.markdown :global(h2) {
@apply text-2xl font-bold my-2;
}
.markdown :global(h3) {
@apply text-xl font-bold my-2;
}
.markdown :global(hr) {
@apply w-[90%] mx-auto my-4 opacity-50;
}
.markdown :global(img) {
@apply max-h-[40vh] border rounded-md border-slate-200 dark:border-zinc-800;
}
.markdown :global(a) {
@apply text-sky-400 hover:underline;
}
.markdown :global(ul) {
@apply list-disc pl-3;
}
.markdown :global(ol) {
@apply list-decimal pl-3;
}
.markdown :global(blockquote) {
@apply border-l-2 border-black/20 dark:border-white/20 pl-2 my-1;
}
</style>
@@ -1,19 +0,0 @@
<script lang="ts">
export let depth: Number
</script>
{#if depth == 1}
<h1 class="font-bold text-3xl my-2"><slot /></h1>
{:else if depth == 2}
<h2 class="font-bold text-2xl my-2"><slot /></h2>
{:else if depth == 3}
<h3 class="font-bold text-xl my-2"><slot /></h3>
{:else if depth == 4}
<h4 class="font-bold text-lg my-2"><slot /></h4>
{:else if depth == 5}
<h5 class="font-bold text-base my-2"><slot /></h5>
{:else if depth == 6}
<h6 class="font-bold text-sm my-2"><slot /></h6>
{:else}
<slot />
{/if}
@@ -1 +0,0 @@
<hr class="w-[90%] mx-auto my-4 opacity-50" />
@@ -1,12 +0,0 @@
<script lang="ts">
export let href: string = ''
export let title: string | undefined = undefined
export let text: string = ''
</script>
<img
src={href}
{title}
alt={text}
class="max-h-[40vh] border rounded-md border-slate-200 dark:border-zinc-800"
/>
@@ -1,5 +0,0 @@
<script lang="ts">
export let href: string
</script>
<a {href} class="text-sky-400 hover:underline"><slot /></a>
@@ -1,10 +0,0 @@
<script lang="ts">
export let ordered: boolean
export let start: number
</script>
{#if ordered}
<ol {start} class="list-decimal pl-3"><slot /></ol>
{:else}
<ul class="list-disc pl-3"><slot /></ul>
{/if}
@@ -1,3 +0,0 @@
<blockquote class="border-l-2 border-black/20 dark:border-white/20 pl-2 my-1">
<slot />
</blockquote>