Skip to content

Commit

Permalink
fix(route/zhihu): Sanitize the title when parsing "pins" with links. (#…
Browse files Browse the repository at this point in the history
…17010)

* fix(route/zhihu): Sanitize the title when parsing "pins" with links.

* Use `sanitizeHtml` instead

---------
  • Loading branch information
dzx-dzx authored Oct 7, 2024
1 parent 3f7c467 commit 471d146
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/routes/zhihu/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 471d146

Please sign in to comment.