mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-05 02:41:34 +00:00
refac: only open web, mail, phone and relative file links (#31491)
File attachment links and the file links in code execution results now go through the same link check as links in chat messages, so only web, mail, phone and relative links are opened.
This commit is contained in:
parent
fc9ad75164
commit
b6f9679985
3 changed files with 6 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { getContext } from 'svelte';
|
||||
import { safeLinkUrl } from '$lib/utils';
|
||||
import CodeBlock from './CodeBlock.svelte';
|
||||
import Modal from '$lib/components/common/Modal.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
|
|
@ -97,7 +98,7 @@
|
|||
<ul class="mt-1 list-disc pl-4 text-xs">
|
||||
{#each codeExecution?.result?.files as file}
|
||||
<li>
|
||||
<a href={file.url} target="_blank">{file.name}</a>
|
||||
<a href={safeLinkUrl(file.url)} target="_blank">{file.name}</a>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import { createEventDispatcher, getContext } from 'svelte';
|
||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||
|
||||
import { formatFileSize } from '$lib/utils';
|
||||
import { formatFileSize, safeLinkUrl } from '$lib/utils';
|
||||
import { settings, showFileNavPath } from '$lib/stores';
|
||||
|
||||
import FileItemModal from './FileItemModal.svelte';
|
||||
|
|
@ -71,7 +71,7 @@
|
|||
} else {
|
||||
window.open(`${WEBUI_API_BASE_URL}/files/${url}/content`, '_blank').focus();
|
||||
}
|
||||
} else {
|
||||
} else if (safeLinkUrl(url)) {
|
||||
window.open(`${url}`, '_blank').focus();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import { getContext, onMount, tick } from 'svelte';
|
||||
|
||||
import { formatFileSize, getLineCount } from '$lib/utils';
|
||||
import { formatFileSize, getLineCount, safeLinkUrl } from '$lib/utils';
|
||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||
import { settings } from '$lib/stores';
|
||||
import { getKnowledgeById } from '$lib/apis/knowledge';
|
||||
|
|
@ -264,7 +264,7 @@
|
|||
href="#"
|
||||
class="hover:underline line-clamp-1"
|
||||
on:click|preventDefault={() => {
|
||||
if (item.type === 'file' || item.url) {
|
||||
if (item.type === 'file' || safeLinkUrl(item.url)) {
|
||||
let fileId = item?.id ?? item?.tempId;
|
||||
window.open(
|
||||
item.type === 'file'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue