security: replace src
This commit is contained in:
7 files changed
+22
-15
No files matched your search
+1
-1
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,15 +23,6 @@
|
||||
...rest
|
||||
}: Props = $props()
|
||||
|
||||
function decodeHtmlEntities(input: string) {
|
||||
return input
|
||||
.replace(/'/g, "'")
|
||||
.replace(/"/g, '"')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/&/g, '&')
|
||||
}
|
||||
|
||||
if (header) {
|
||||
type = 'tablecell'
|
||||
}
|
||||
@@ -50,7 +41,7 @@
|
||||
{...rest}
|
||||
/>
|
||||
{:else if token.text}
|
||||
{decodeHtmlEntities(token.text)}
|
||||
{token.text}
|
||||
{:else if text}
|
||||
{text}
|
||||
{/if}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user