feedparser
Advanced tools
Comparing version 0.18.1 to 0.19.0
v0.19.0 / 2014-07-30 | ||
================== | ||
* Remove unnecessary code to trigger saxparser error. Apparently, calling the callback with an error will trigger an error anyway. Totally undocumented. So, this was actually calling double error emitting. | ||
* Manually trigger end when an exception is caught. We can't continue parsing after an exception is thrown. Also update test. | ||
* Use native try/catch. Other method is not a performance enhancement. | ||
* Wrap sax write and end methods in try/catch. Resolves #112 sax >= v0.6.0 can throw if a gzipped data stream containing certain characters gets written to the parser. This is a user error (to pipe gzipped data), but sometimes servers send gzipped data even when you've told them not to. So, we try to let the user handle this more gracefully. | ||
* Add failing test case for sax throwing | ||
v0.18.1 / 2014-06-20 | ||
@@ -3,0 +12,0 @@ ================== |
19
main.js
@@ -1023,11 +1023,22 @@ /********************************************************************** | ||
FeedParser.prototype._transform = function (data, encoding, done) { | ||
this.stream.write(data); | ||
done(); | ||
try { | ||
this.stream.write(data); | ||
done(); | ||
} | ||
catch (e) { | ||
done(e); | ||
this.push(null); // Manually trigger and end, since we can't reliably do any more parsing | ||
} | ||
}; | ||
FeedParser.prototype._flush = function (done) { | ||
this.stream.end(); | ||
done(); | ||
try { | ||
this.stream.end(); | ||
done(); | ||
} | ||
catch (e) { | ||
done(e); | ||
} | ||
}; | ||
exports = module.exports = FeedParser; |
@@ -5,3 +5,3 @@ { | ||
"description": "Robust RSS Atom and RDF feed parsing using sax js", | ||
"version": "0.18.1", | ||
"version": "0.19.0", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "rss", |
@@ -26,2 +26,3 @@ describe('bad feeds', function(){ | ||
describe('duplicate guids', function () { | ||
var feed = __dirname + '/feeds/guid-dupes.xml'; | ||
@@ -42,3 +43,24 @@ | ||
}); | ||
}); | ||
}); | ||
describe('gzipped feed', function () { | ||
var feed = __dirname + '/feeds/invalid-characters-gzipped.xml'; | ||
it('should gracefully emit an error and not throw', function (done) { | ||
var error; | ||
fs.createReadStream(feed).pipe(new FeedParser()) | ||
.once('readable', function () { | ||
done(new Error('Shouldn\'t happen')); | ||
}) | ||
.on('error', function (err) { | ||
error = err; | ||
}) | ||
.on('end', function () { | ||
assert.ok(error instanceof Error); | ||
assert.ok(error.message.match(/^Invalid code point/)); | ||
done(); | ||
}); | ||
}); | ||
@@ -45,0 +67,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
573630
38
1643