From 471d146dffd684605cb44f801a2fb78aebaddd6a Mon Sep 17 00:00:00 2001 From: Andvari <31068367+dzx-dzx@users.noreply.github.com> Date: Mon, 7 Oct 2024 08:54:44 +0800 Subject: [PATCH] fix(route/zhihu): Sanitize the title when parsing "pins" with links. (#17010) * fix(route/zhihu): Sanitize the title when parsing "pins" with links. * Use `sanitizeHtml` instead --------- --- lib/routes/zhihu/activities.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/routes/zhihu/activities.ts b/lib/routes/zhihu/activities.ts index 29c8b8cc1..62b45b364 100644 --- a/lib/routes/zhihu/activities.ts +++ b/lib/routes/zhihu/activities.ts @@ -2,6 +2,7 @@ import { Route, ViewType } from '@/types'; import got from '@/utils/got'; import { header, processImage, getSignedHeader } from './utils'; import { parseDate } from '@/utils/parse-date'; +import sanitizeHtml from 'sanitize-html'; export const route: Route = { path: '/people/activities/:id', @@ -75,7 +76,7 @@ async function handler(ctx) { url = `https://zhuanlan.zhihu.com/p/${detail.id}`; break; case 'pin': - title = detail.excerpt_title; + title = sanitizeHtml(detail.excerpt_title); author = detail.author.name; for (const contentItem of detail.content) { switch (contentItem.type) {