Skip to content

Commit 5c4d882

Browse files
committed
fix: exported opml should escape to valid xml
1 parent aa56240 commit 5c4d882

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

source/middlewares/export-to-opml.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as fs from 'fs';
66
import { config } from '../config';
77
import { MContext, Next } from '../types/ctx';
88
import { Feed } from '../types/feed';
9+
import { htmlEscape } from 'escape-goat';
910

1011
function readFilePromise(path: string): Promise<string> {
1112
return new Promise((resolve, reject) => {
@@ -26,7 +27,10 @@ const render = async (feeds: Feed[]): Promise<string> => {
2627
const tpl = await readFilePromise(
2728
path.join(__dirname, '../template/opml.ejs')
2829
);
29-
// console.log(tpl)
30+
feeds.forEach((feed) => {
31+
feed.feed_title = htmlEscape(feed.feed_title);
32+
feed.url = htmlEscape(feed.url);
33+
});
3034
return ejs.render(tpl, { feeds });
3135
};
3236

0 commit comments

Comments
 (0)