From 1a33ed90a4e695b528c202706d134989dc2a97cc Mon Sep 17 00:00:00 2001 From: Ou Date: Sun, 27 Oct 2024 00:16:56 +0800 Subject: [PATCH] fix(source): jin10 for disable code generation from strings disallowed for this context --- server/sources/jin10.ts | 8 +++++--- shared/sources.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/sources/jin10.ts b/server/sources/jin10.ts index 0814f26..aab1e4e 100644 --- a/server/sources/jin10.ts +++ b/server/sources/jin10.ts @@ -25,9 +25,11 @@ export default defineSource(async () => { const rawData: string = await $fetch(url) - // eslint-disable-next-line no-new-func - const jsonStr = new Function(`${rawData}\nreturn newest;`) - const data: Jin10Item[] = jsonStr() + const jsonStr = (rawData as string) + .replace(/^var\s+newest\s*=\s*/, "") // 移除开头的变量声明 + .replace(/;*$/, "") // 移除末尾可能存在的分号 + .trim() // 移除首尾空白字符 + const data: Jin10Item[] = JSON.parse(jsonStr) return data.filter(k => (k.data.title || k.data.content) && !k.channel?.includes(5)).map((k) => { const text = (k.data.title || k.data.content)!.replace(/<\/?b>/g, "") diff --git a/shared/sources.ts b/shared/sources.ts index f5bbd1d..a8f8d3d 100644 --- a/shared/sources.ts +++ b/shared/sources.ts @@ -269,7 +269,7 @@ export const originSources = { "jin10": { name: "金十数据", column: "finance", - color: "red", + color: "blue", home: "https://www.jin10.com", }, } as const satisfies Record