Bug 1139560 - Fix srcset parser 'After descriptor' state mishandling spaces. r=jst, a=sledru
authorJohn Schoenick <john@pointysoftware.net>
Wed, 04 Mar 2015 23:11:00 -0500
changeset 258437 07666fc071bede5e3a2412785a19c4a6854fbdcb
parent 258436 dffb5c867f476431f65783822d0e2b380f58d7e0
child 258438 7285a02cd883fa1b3ab150985318f8268559b454
push id4668
push userryanvm@gmail.com
push dateMon, 13 Apr 2015 16:23:34 +0000
treeherdermozilla-beta@002faed66e96 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst, sledru
bugs1139560
milestone38.0
Bug 1139560 - Fix srcset parser 'After descriptor' state mishandling spaces. r=jst, a=sledru
dom/base/ResponsiveImageSelector.cpp
--- a/dom/base/ResponsiveImageSelector.cpp
+++ b/dom/base/ResponsiveImageSelector.cpp
@@ -616,21 +616,23 @@ ResponsiveImageCandidate::ConsumeDescrip
         // before breaking
         descriptors.AddDescriptor(Substring(currentDescriptor, iter));
         iter++;
         break;
       } else if (nsContentUtils::IsHTMLWhitespace(*iter)) {
         // End of current descriptor, consume it, skip spaces
         // ("After descriptor" state in spec) before continuing
         descriptors.AddDescriptor(Substring(currentDescriptor, iter));
-        for (; iter != end && *iter == char16_t(' '); ++iter);
+        for (; iter != end && nsContentUtils::IsHTMLWhitespace(*iter); ++iter);
         if (iter == end) {
           break;
         }
         currentDescriptor = iter;
+        // Leave one whitespace so the loop advances to this position next iteration
+        iter--;
       } else if (*iter == char16_t('(')) {
         inParens = true;
       }
     }
   }
 
   descriptors.FillCandidate(*this);