# HG changeset patch # User MakeMyDay # Date 1512932539 -3600 # So Dez 10 20:02:19 2017 +0100 # Node ID 8c2e2bb95746a38c4df4677f8a37f04c19da83e8 # Parent 9e1b188a45875c0ee93fc508dff571074567c62b Bug 1394524 - Fail gracefully when parsing invalid ics data. r=philipp diff --git a/calendar/base/src/calIcsParser.js b/calendar/base/src/calIcsParser.js --- a/calendar/base/src/calIcsParser.js +++ b/calendar/base/src/calIcsParser.js @@ -137,17 +137,33 @@ calIcsParser.prototype = { self.processIcalComponent(rootComp, aAsyncParsing); } else { cal.ERROR("Error Parsing ICS: " + rc); aAsyncParsing.onParsingComplete(rc, self); } } }); } else { - this.processIcalComponent(cal.getIcsService().parseICS(aICSString, aTzProvider)); + try { + let icalComp = cal.getIcsService().parseICS(aICSString, aTzProvider); + // There is no such indicator like X-LIC in icaljs, so there would need to + // detect and log such errors already within the parser. However, until + // X-LIC or libical will be removed we make use of X-LIC-ERRORS here but + // don't add something similar to icaljs + if (icalComp.toString().match(/X-LIC-ERROR/)) { + cal.WARN( + "Parsing failed for parts of the item (while this is considered " + + "to be a minor issue, we continue processing the item):\n" + + icalComp.toString() + ); + } + this.processIcalComponent(icalComp); + } catch (exc) { + cal.ERROR(exc.message + " when parsing\n" + aICSString); + } } }, parseFromStream: function(aStream, aTzProvider, aAsyncParsing) { // Read in the string. Note that it isn't a real string at this point, // because likely, the file is utf8. The multibyte chars show up as multiple // 'chars' in this string. So call it an array of octets for now.