From 18b34fce71a0cdffd8a8ccb85a54859fc335715d Mon Sep 17 00:00:00 2001 From: ColdThunder11 <34985592+ColdThunder11@users.noreply.github.com> Date: Sat, 17 Sep 2022 21:24:28 +0800 Subject: [PATCH] fix(route): bilibili dynamic (#10815) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(route): bilibili dynamic error when emoji contains ? 修复bilibili动态在特定表情下会产生正则表达式错误的问题 * fix(route): bilibili dynamic change line 修复bilibili态内容换行问题 * fix: deepscan warning --- lib/v2/bilibili/dynamic.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/v2/bilibili/dynamic.js b/lib/v2/bilibili/dynamic.js index 384e520b81..4703ac4e15 100644 --- a/lib/v2/bilibili/dynamic.js +++ b/lib/v2/bilibili/dynamic.js @@ -1,6 +1,7 @@ const got = require('@/utils/got'); const JSONbig = require('json-bigint'); const utils = require('./utils'); +const { parseDate } = require('@/utils/parse-date'); /** @by CaoMeiYouRen 2020-05-05 添加注释 @@ -155,11 +156,13 @@ module.exports = async (ctx) => { // emoji let data_content = getDes(data); + // 换行处理 + data_content = data_content.replace(new RegExp('\r\n', 'g'), '
').replace(new RegExp('\n', 'g'), '
'); if (item.display.emoji_info) { const emoji = item.display.emoji_info.emoji_details; emoji.forEach((item) => { data_content = data_content.replace( - new RegExp(`\\${item.text}`, 'g'), + new RegExp(`\\${item.text}`.replace(new RegExp('\\?', 'g'), '\\?'), 'g'), `${item.text}` ); }); @@ -198,7 +201,7 @@ module.exports = async (ctx) => { const videoHTMLSource = videoHTML ? `
${videoHTML}` : ''; return `${description}${originName}
${getUrl(data)}${getUrl(origin)}${getIframe(data)}${getIframe(origin)}${imgHTMLSource}${videoHTMLSource}`; })(), - pubDate: new Date(item.desc.timestamp * 1000), + pubDate: item.desc ? (item.desc.timestamp ? parseDate(item.desc.timestamp, 'X') : null) : null, link, }; }),