Bug 1139554 - Fix srcset parser mishandling bare URLs followed by a comma. r=jst
authorJohn Schoenick <john@pointysoftware.net>
Wed, 04 Mar 2015 23:07:00 -0500
changeset 236152 dedb3abd07fc4393b29dfcb0b86237334a08777e
parent 236151 b05e10ed40c4e6569a9bb48e73b732ffb7a13257
child 236153 768fcbee6319132f1bab327baf9e3371e4bc45ca
push id57604
push userjosh@joshmatthews.net
push dateFri, 27 Mar 2015 18:39:41 +0000
treeherdermozilla-inbound@dedb3abd07fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs1139554
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1139554 - Fix srcset parser mishandling bare URLs followed by a comma. r=jst
dom/base/ResponsiveImageSelector.cpp
testing/web-platform/meta/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html.ini
--- a/dom/base/ResponsiveImageSelector.cpp
+++ b/dom/base/ResponsiveImageSelector.cpp
@@ -98,30 +98,28 @@ ResponsiveImageSelector::SetCandidatesFr
       break;
     }
 
     url = iter;
 
     // Find end of url
     for (;iter != end && !nsContentUtils::IsHTMLWhitespace(*iter); ++iter);
 
-    urlEnd = iter;
-
     // Omit trailing commas from URL.
     // Multiple commas are a non-fatal error.
-    while (urlEnd != url) {
-      if (*(--urlEnd) != char16_t(',')) {
-        urlEnd++;
+    while (iter != url) {
+      if (*(--iter) != char16_t(',')) {
+        iter++;
         break;
       }
     }
 
-    const nsDependentSubstring &urlStr = Substring(url, urlEnd);
+    const nsDependentSubstring &urlStr = Substring(url, iter);
 
-    MOZ_ASSERT(url != urlEnd, "Shouldn't have empty URL at this point");
+    MOZ_ASSERT(url != iter, "Shouldn't have empty URL at this point");
 
     ResponsiveImageCandidate candidate;
     if (candidate.ConsumeDescriptors(iter, end)) {
       candidate.SetURLSpec(urlStr);
       AppendCandidateIfUnique(candidate);
     }
   }
 
--- a/testing/web-platform/meta/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html.ini
+++ b/testing/web-platform/meta/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html.ini
@@ -25,40 +25,19 @@
     expected: FAIL
 
   ["data:,a { , data:,b 1x, }, data:,c"]
     expected: FAIL
 
   ["data:,a \\" , data:,b 1x, \\", data:,c"]
     expected: FAIL
 
-  ["data:,a \\\\,data:;\\,b, data:,c"]
-    expected: FAIL
-
-  ["data:,a, data:,b ("]
-    expected: FAIL
-
-  ["data:,a, data:,b (  "]
-    expected: FAIL
-
-  ["data:,a, data:,b (,"]
-    expected: FAIL
-
-  ["data:,a, data:,b (x"]
-    expected: FAIL
-
-  ["data:,a, data:,b ()"]
-    expected: FAIL
-
   ["data:,a (, data:,b"]
     expected: FAIL
 
-  ["data:,a /*, data:,b, data:,c */"]
-    expected: FAIL
-
   ["data:,a foo"]
     expected: FAIL
 
   ["data:,a foo foo"]
     expected: FAIL
 
   ["data:,a foo 1x"]
     expected: FAIL