From 0c6a86543cc2a045b7075ebdfe1600abb88891cf Mon Sep 17 00:00:00 2001 From: Vincent Giersch Date: Fri, 18 Sep 2015 22:14:21 +0200 Subject: [PATCH] fix(lib): add missing hasOwnProperty when iterating over objects keys Signed-off-by: Vincent Giersch --- lib/emailreplyparser.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/emailreplyparser.js b/lib/emailreplyparser.js index 445a831..7f1eb54 100644 --- a/lib/emailreplyparser.js +++ b/lib/emailreplyparser.js @@ -121,7 +121,8 @@ Email.prototype = { var visible_text = []; for (var key in this.fragments) { - if (!this.fragments[key].hidden || (include_signatures && this.fragments[key].signature)) { + if (this.fragments.hasOwnProperty(key) && + !this.fragments[key].hidden || (include_signatures && this.fragments[key].signature)) { visible_text.push(this.fragments[key].to_s()); } } @@ -168,7 +169,9 @@ Email.prototype = { var lines = text.split('\n'); for(var i in lines) { - this.scan_line(lines[i]); + if (lines.hasOwnProperty(i)) { + this.scan_line(lines[i]); + } } // Finish up the final fragment. Finishing a fragment will detect any @@ -316,4 +319,4 @@ Fragment.prototype = { module.exports.EmailReplyParser = EmailReplyParser; -//console.log(EmailReplyParser.read("I get proper rendering as well.\n\nSent from a magnificent torch of pixels\n\nOn Dec 16, 2011, at 12:47 PM, Corey Donohoe\n\nwrote:\n\n> Was this caching related or fixed already? I get proper rendering here.\n>\n> ![](https://img.skitch.com/20111216-m9munqjsy112yqap5cjee5wr6c.jpg)\n>\n> ---\n> Reply to this email directly or view it on GitHub:\n> https://github.com/github/github/issues/2278#issuecomment-3182418\n")); \ No newline at end of file +//console.log(EmailReplyParser.read("I get proper rendering as well.\n\nSent from a magnificent torch of pixels\n\nOn Dec 16, 2011, at 12:47 PM, Corey Donohoe\n\nwrote:\n\n> Was this caching related or fixed already? I get proper rendering here.\n>\n> ![](https://img.skitch.com/20111216-m9munqjsy112yqap5cjee5wr6c.jpg)\n>\n> ---\n> Reply to this email directly or view it on GitHub:\n> https://github.com/github/github/issues/2278#issuecomment-3182418\n"));