mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
在转发 Telegram Channel 到 Mastodon 的过程中,发现有两处格式错误: 1. hashtag 和斜体内容, Mastodon 不支持,就变成 `<i>#tag</i>` 这样的形式了,版式很乱且没必要,这个一般用的也少,干脆就去掉了。 2. 在去除不可见字符的时候,应当保留回车 `\r \n` ,这样可以更好的保持排版格式。(源代码中参照的 stackoverflow 链接中的第二个,回答中的提示也有保留回车的选项,就套过来了。
7 lines
421 B
JavaScript
7 lines
421 B
JavaScript
// https://stackoverflow.com/questions/2507608/error-input-is-not-proper-utf-8-indicate-encoding-using-phps-simplexml-lo/40552083#40552083
|
|
// https://stackoverflow.com/questions/1497885/remove-control-characters-from-php-string/1497928#1497928
|
|
module.exports = async (ctx, next) => {
|
|
await next();
|
|
ctx.body = typeof ctx.body !== 'object' ? ctx.body.replace(/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/g, '') : ctx.body;
|
|
};
|