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

---------
This commit is contained in:
Andvari 2024-10-07 08:54:44 +08:00 committed by GitHub
parent 3f7c467b70
commit 471d146dff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -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) {