security: replace src

This commit is contained in:
Xylight committed 2025-11-20 18:28:33 -08:00
1 parent 7c322310e9
commit 385a7dbc40
7 files changed
+22 -15

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ export abstract class BaseClient {
}
static async fetchInfo(
base: string,
base: string | URL,
): Promise<{ type: ClientType; version: string } | null> {
try {
const res = await fetch(new URL('/nodeinfo/2.1', base))
+8 -2
View File
@@ -29,8 +29,14 @@
import MdTableHead from './renderers/table/MdTableHead.svelte'
import MdTableRow from './renderers/table/MdTableRow.svelte'
function preprocess(src: string) {
return src
.replaceAll(/\[([^\]]*)\]\(\s*javascript:[^)]*\)/gim, '*link removed*')
.replaceAll(/^\s*\[[^\]]+\]:\s*javascript:.*$/gim, '*link removed*')
}
marked.setOptions({
gfm: true,
gfm: false,
breaks: false,
})
@@ -141,7 +147,7 @@
noStyle: noStyle,
})
let tokens = $derived(marked.lexer(source))
let tokens = $derived(marked.lexer(preprocess(source)))
</script>
<svelte:element
+1 -10
View File
@@ -23,15 +23,6 @@
...rest
}: Props = $props()
function decodeHtmlEntities(input: string) {
return input
.replace(/&#39;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&amp;/g, '&')
}
if (header) {
type = 'tablecell'
}
@@ -50,7 +41,7 @@
{...rest}
/>
{:else if token.text}
{decodeHtmlEntities(token.text)}
{token.text}
{:else if text}
{text}
{/if}
+3 -1
View File
@@ -60,7 +60,9 @@
})
async function checkInstance() {
const type = await BaseClient.fetchInfo(instanceToURL(form.instance))
const type = await BaseClient.fetchInfo(
new URL(instanceToURL(form.instance)),
)
if (type == null) throw Error('not_live_supported')
form.client = type?.type
}
+3 -1
View File
@@ -39,7 +39,9 @@
})
async function checkInstance() {
const type = await BaseClient.fetchInfo(instanceToURL(form.instance))
const type = await BaseClient.fetchInfo(
new URL(instanceToURL(form.instance)),
)
if (type == null) throw Error('not_live_supported')
form.client = type?.type
}