fix(source): jin10 for disable code generation from strings disallowed for this context

This commit is contained in:
Ou 2024-10-27 00:16:56 +08:00
parent 4daeb0edd4
commit 1a33ed90a4
2 changed files with 6 additions and 4 deletions

View File

@ -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, "")

View File

@ -269,7 +269,7 @@ export const originSources = {
"jin10": {
name: "金十数据",
column: "finance",
color: "red",
color: "blue",
home: "https://www.jin10.com",
},
} as const satisfies Record<string, OriginSource>