Bug 1139554 - Fix srcset parser mishandling bare URLs followed by a comma. r=jst
☠☠ backed out by e99d72e0a529 ☠ ☠
authorJohn Schoenick <john@pointysoftware.net>
Wed, 04 Mar 2015 23:07:00 -0500
changeset 266362 2c368e6b267e29f2d178da85f4fbaf38d0efb34a
parent 266361 0ed97c76d58cfaf299b1dc2e4586d489a488ef1f
child 266363 ad2032c2de8c5819f8e85ef71eb679765bbd9263
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [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
--- 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);
     }
   }