Skip to content

Commit 0b77cfc

Browse files
committed
Skip illegally-nested items
1 parent 9a25840 commit 0b77cfc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/feedparser/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ FeedParser.prototype.handleCloseTag = function (el){
213213
, stdEl
214214
, item
215215
, baseurl
216+
, isIllegallyNested = false
216217
;
217218
var n = this.stack.shift();
218219
el = el.split(':');
@@ -297,6 +298,17 @@ FeedParser.prototype.handleCloseTag = function (el){
297298
(node['#local'] === 'item' && (node['#prefix'] === '' || node['#type'] === 'rdf')) ||
298299
(node['#local'] == 'entry' && (node['#prefix'] === '' || node['#type'] === 'atom'))) { // We have an article!
299300

301+
isIllegallyNested = (
302+
( node['#name'] === 'item' && this.stack[0]['#name'] === 'item' ) ||
303+
( node['#name'] === 'entry' && this.stack[0]['#name'] === 'entry' ) ||
304+
( (node['#local'] === 'item' && (node['#prefix'] === '' || node['#type'] === 'rdf')) && this.stack[0]['#name'] === 'item' ) ||
305+
( (node['#local'] == 'entry' && (node['#prefix'] === '' || node['#type'] === 'atom')) && this.stack[0]['#name'] === 'entry' )
306+
);
307+
308+
if (isIllegallyNested) {
309+
return;
310+
}
311+
300312
if (!this.meta.title) { // We haven't yet parsed all the metadata
301313
_.assign(this.meta, this.handleMeta(this.stack[0], this.meta['#type'], this.options));
302314
if (!this._emitted_meta) {

0 commit comments

Comments
 (0)