mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-27 13:46:37 +08:00
refactor: improve URL validation in readFileContent
This commit is contained in:
parent
e86a39047c
commit
40947a5fa7
@ -19,7 +19,8 @@ export function trimTopic(topic: string) {
|
||||
|
||||
export const readFileContent = async (file: UploadFile): Promise<string> => {
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user