mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-09 22:33:29 +00:00
refac: validate the citation embed URL before use (#29701)
A citation's embed_url now has to be an http or https URL, or protocol-relative, before it is opened or handed to the embed panel. Anything else falls back to the citation modal, which already renders the source.
This commit is contained in:
parent
cb942bb94c
commit
831b3b0df2
1 changed files with 6 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { getContext } from 'svelte';
|
||||
import { embed, showControls, showEmbeds } from '$lib/stores';
|
||||
import { isValidHttpUrl } from '$lib/utils';
|
||||
|
||||
import CitationModal from './Citations/CitationModal.svelte';
|
||||
|
||||
|
|
@ -43,7 +44,11 @@
|
|||
|
||||
if (citations[index]?.source?.embed_url) {
|
||||
const embedUrl = citations[index].source.embed_url;
|
||||
if (embedUrl) {
|
||||
// The embed panel renders anything it cannot read as a URL as raw HTML
|
||||
if (
|
||||
typeof embedUrl === 'string' &&
|
||||
(isValidHttpUrl(embedUrl) || embedUrl.startsWith('//'))
|
||||
) {
|
||||
if (readOnly) {
|
||||
// Open in new tab if readOnly
|
||||
window.open(embedUrl, '_blank');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue