diff --git a/changelog.d/670.bugfix b/changelog.d/670.bugfix new file mode 100644 index 00000000..8eecea0d --- /dev/null +++ b/changelog.d/670.bugfix @@ -0,0 +1 @@ +Relax the Feed parser so that it allows RSS feeds with HTML elements in them. \ No newline at end of file diff --git a/src/feeds/FeedReader.ts b/src/feeds/FeedReader.ts index 515e8b02..2c1f2dea 100644 --- a/src/feeds/FeedReader.ts +++ b/src/feeds/FeedReader.ts @@ -88,6 +88,16 @@ function normalizeUrl(input: string): string { } export class FeedReader { + + private readonly parser = new Parser({ + xml2js: { + // Allow HTML bodies, such as value-less attributes. + strict: false, + // The parser will break if we don't do this, as it defaults to `res.FEED` rather than `res.feed`. + normalizeTags: true, + } + }); + private connections: FeedConnection[]; // ts should notice that we do in fact initialize it in constructor, but it doesn't (in this version) private observedFeedUrls: Set = new Set(); @@ -197,7 +207,7 @@ export class FeedReader { this.cacheTimes.set(url, { lastModified: res.headers['Last-Modified'] }); } - const feed = await (new Parser()).parseString(res.data); + const feed = await this.parser.parseString(res.data); let initialSync = false; let seenGuids = this.seenEntries.get(url); if (!seenGuids) {