Bug 1139554 - Fix srcset parser mishandling bare URLs followed by a comma. r=jst, a=sledru
authorJohn Schoenick <john@pointysoftware.net>
Wed, 04 Mar 2015 23:07:00 -0500
changeset 258370 a9d1df7af6fc
parent 258369 2d8d16d8c2ad
child 258371 ac9862939f3e
push id4654
push userryanvm@gmail.com
push date2015-04-08 19:02 +0000
treeherdermozilla-beta@01cf08a90d44 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst, sledru
bugs1139554
milestone38.0
Bug 1139554 - Fix srcset parser mishandling bare URLs followed by a comma. r=jst, a=sledru
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