From a82fc7bc8ab1dbbfce80a724a6bbdd6dd11ec4d8 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Sat, 4 Sep 2021 02:43:58 +0200 Subject: [PATCH] Recover from feed XML parsing error --- lib/www/client/source/src/views/Feed.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/www/client/source/src/views/Feed.vue b/lib/www/client/source/src/views/Feed.vue index c77ad15..8ac5fb3 100644 --- a/lib/www/client/source/src/views/Feed.vue +++ b/lib/www/client/source/src/views/Feed.vue @@ -82,9 +82,23 @@ export default { return data; }, + /** Try to fix idiosyncrasies and XML bugs in the source. + */ + fixText (text) { + // Of course this will fail if there happens to be an + // element in the source. + return text.replace(/(]*)?>)/g, "$1") + }, + async refresh () { const text = await this.api([`/rss/?remote=${atob(this.$route.params.source)}`, {text:true}]); - this.feed = this.parse(text); + try { + this.feed = this.parse(text); + } catch (err) { + // If it failed to parse, try once again with some + // tweaks to address known feed bugs. + this.feed = this.parse(this.fixText(text)); + } }, ...mapActions(["api"])