mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-25 17:00:52 -04: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:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user