From 5c4d882879b6569bd7734ee09776365686cb7010 Mon Sep 17 00:00:00 2001 From: fengkx Date: Wed, 4 Nov 2020 10:24:51 +0800 Subject: [PATCH] fix: exported opml should escape to valid xml --- source/middlewares/export-to-opml.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/middlewares/export-to-opml.ts b/source/middlewares/export-to-opml.ts index 138cfa07820..9aac373ef81 100644 --- a/source/middlewares/export-to-opml.ts +++ b/source/middlewares/export-to-opml.ts @@ -6,6 +6,7 @@ import * as fs from 'fs'; import { config } from '../config'; import { MContext, Next } from '../types/ctx'; import { Feed } from '../types/feed'; +import { htmlEscape } from 'escape-goat'; function readFilePromise(path: string): Promise { return new Promise((resolve, reject) => { @@ -26,7 +27,10 @@ const render = async (feeds: Feed[]): Promise => { const tpl = await readFilePromise( path.join(__dirname, '../template/opml.ejs') ); - // console.log(tpl) + feeds.forEach((feed) => { + feed.feed_title = htmlEscape(feed.feed_title); + feed.url = htmlEscape(feed.url); + }); return ejs.render(tpl, { feeds }); };