From 0146a96c6f76c683d4767621e9a1a49cb0fbf95a Mon Sep 17 00:00:00 2001 From: Chris Moyer Date: Thu, 25 Aug 2016 11:22:35 -0400 Subject: [PATCH] Handles broken RSS feeds that may not include an declaration. An example feed is: http://stocknewsnow.com/feed/. The feed is a semi-valid RSS feed, it's just missing the global declaration. --- main.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.js b/main.js index e1dfda5..9729949 100644 --- a/main.js +++ b/main.js @@ -175,6 +175,7 @@ FeedParser.prototype.handleOpenTag = function (node){ this.xhtml['#'] += '>'; } else if ( this.stack.length === 0 && (n['#name'] === 'rss' || + (!this.meta['#type'] && n['#name'] === 'channel') || (n['#local'] === 'rdf' && utils.nslookup([n['#uri']], 'rdf')) || (n['#local'] === 'feed'&& utils.nslookup([n['#uri']], 'atom')) ) ) { Object.keys(n['@']).forEach(function(name) { @@ -189,6 +190,10 @@ FeedParser.prototype.handleOpenTag = function (node){ this.meta['#type'] = 'rss'; this.meta['#version'] = n['@']['version']; break; + case 'channel': + this.meta['#type'] = 'rss'; + this.meta['#version'] = n['@']['version']; + break; case 'rdf': this.meta['#type'] = 'rdf'; this.meta['#version'] = n['@']['version'] || '1.0';