Bug 875739 - Freeze (hang) on .ics file which has two CN (common name) parameters or duplicated X-params set on the ATTENDEE/ORGANIZER property. r=Philipp
authordiesmo <partoche@yahoo.com>
Fri, 10 Jun 2016 08:17:46 +0200
changeset 19439 053758b8389e73c42a1bd309f9d99ca8402f5de3
parent 19438 03959f38f7bb948df1b0a2cdb20c829d09c582cb
child 19440 de9936da55acede438b8e11a2baab69246b9ef28
push id11967
push userbv1578@gmail.com
push dateFri, 10 Jun 2016 06:47:57 +0000
treeherdercomm-central@7533feed2f23 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPhilipp
bugs875739
Bug 875739 - Freeze (hang) on .ics file which has two CN (common name) parameters or duplicated X-params set on the ATTENDEE/ORGANIZER property. r=Philipp
calendar/base/modules/calIteratorUtils.jsm
--- a/calendar/base/modules/calIteratorUtils.jsm
+++ b/calendar/base/modules/calIteratorUtils.jsm
@@ -208,26 +208,38 @@ cal.ical = {
      *   for (let [paramName, paramValue] of cal.ical.paramIterator(prop)) { ... }
      *
      * @param aProperty         The property to iterate.
      * @return                  An iterator object to iterate the properties.
      */
     paramIterator: function cal_ical_paramIterator(aProperty) {
         return {
             __iterator__: function icalParamIterator(aWantKeys) {
+                let paramSet = new Set();
                 for (let paramName = aProperty.getFirstParameterName();
                      paramName;
                      paramName = aProperty.getNextParameterName()) {
-                    yield (aWantKeys ? paramName :
-                           [paramName, aProperty.getParameter(paramName)]);
+                    // Workaround to avoid infinite loop when the property
+                    // contains duplicate parameters (bug 875739 for libical)
+                    if (!paramSet.has(paramName)) {
+                        yield (aWantKeys ? paramName :
+                                           [paramName, aProperty.getParameter(paramName)]);
+                        paramSet.add(paramName);
+                    }
                 }
             },
             [Symbol.iterator]: function* icalParamIterator() {
+                let paramSet = new Set();
                 for (let paramName = aProperty.getFirstParameterName();
                      paramName;
                      paramName = aProperty.getNextParameterName()) {
-                    yield [paramName, aProperty.getParameter(paramName)];
+                    // Workaround to avoid infinite loop when the property
+                    // contains duplicate parameters (bug 875739 for libical)
+                    if (!paramSet.has(paramName)) {
+                        yield [paramName, aProperty.getParameter(paramName)];
+                        paramSet.add(paramName);
+                    }
                 }
             }
         };
     }
 };