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 07666fc071be
parent 258436 dffb5c867f47
child 258438 7285a02cd883
push id4668
push userryanvm@gmail.com
push date2015-04-13 16:23 +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);