update frontend and switch sanitize library

This commit is contained in:
2022-07-13 22:57:41 +02:00
parent ff36d375ea
commit 2bb256b07e
9 changed files with 345 additions and 368 deletions

View File

@@ -2,9 +2,9 @@
import type { FileDTO, NotePublic } from '$lib/api'
import { Files } from '$lib/files'
import copy from 'copy-to-clipboard'
import DOMPurify from 'dompurify'
import { saveAs } from 'file-saver'
import prettyBytes from 'pretty-bytes'
import sanitize from 'sanitize-html'
import { t } from 'svelte-intl-precompile'
import Button from './Button.svelte'
@@ -31,11 +31,11 @@
}
function contentWithLinks(content: string): string {
const replaced = note.contents.replace(
const replaced = content.replace(
RE_URL,
(url) => `<a href="${url}" rel="noreferrer">${url}</a>`
)
return sanitize(replaced, { allowedTags: ['a'], allowedAttributes: { a: ['href', 'rel'] } })
return DOMPurify.sanitize(replaced, { USE_PROFILES: { html: true } })
}
</script>

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { create, Note, PayloadToLargeError } from '$lib/api'
import type { Note } from '$lib/api'
import { create, PayloadToLargeError } from '$lib/api'
import { encrypt, getKeyFromString, getRandomBytes, Hex } from '$lib/crypto'
import { status } from '$lib/stores/status'
import Button from '$lib/ui/Button.svelte'

View File

@@ -100,7 +100,7 @@
header svg {
width: 100%;
max-width: 16rem;
max-height: 8rem;
transform: translateX(-1rem);
fill: currentColor;
}