Skip to content

Commit

Permalink
fix: exported opml should escape to valid xml
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx committed Nov 4, 2020
1 parent aa56240 commit 5c4d882
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/middlewares/export-to-opml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
return new Promise((resolve, reject) => {
Expand All @@ -26,7 +27,10 @@ const render = async (feeds: Feed[]): Promise<string> => {
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 });
};

Expand Down

0 comments on commit 5c4d882

Please sign in to comment.