From 40947a5fa7542430e2f8e6aeef8dbdf01553e4a9 Mon Sep 17 00:00:00 2001 From: dakai Date: Fri, 7 Feb 2025 01:50:48 +0800 Subject: [PATCH] refactor: improve URL validation in readFileContent --- app/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/utils.ts b/app/utils.ts index c7664f171..c5107109b 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -19,7 +19,8 @@ export function trimTopic(topic: string) { export const readFileContent = async (file: UploadFile): Promise => { const host_url = new URL(window.location.href); - if (!file.url.includes(host_url.host)) { + const file_url = new URL(file.url); + if (file_url.host !== host_url.host) { throw new Error(`The URL ${file.url} is not allowed to access.`); } try {