Bug 953360 - <a ping> attribute should split on white space not only space r=jst
authorRobert Longson <longsonr@gmail.com>
Sun, 18 May 2014 09:51:16 +0200
changeset 184194 c2c91ff3ec49173f8d46492ea3bf6f6fbbe675db
parent 184193 e8edc293a0818a5e71ddbf7e051460a1d581363d
child 184195 d49aee2034aed7faa183f9f8e7a237417132c8e7
push id26814
push userryanvm@gmail.com
push dateWed, 21 May 2014 19:50:12 +0000
treeherdermozilla-central@7aee2fa0f655 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs953360
milestone32.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 953360 - <a ping> attribute should split on white space not only space r=jst
docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -68,16 +68,17 @@
 #include "nsITimedChannel.h"
 #include "nsIPrivacyTransitionObserver.h"
 #include "nsIReflowObserver.h"
 #include "nsIScrollObserver.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIChannel.h"
 #include "IHistory.h"
 #include "nsViewSourceHandler.h"
+#include "nsWhitespaceTokenizer.h"
 
 // we want to explore making the document own the load group
 // so we can associate the document URI with the load group.
 // until this point, we have an evil hack:
 #include "nsIHttpChannelInternal.h"  
 #include "nsPILoadGroupInternal.h"
 
 // Local Includes
@@ -361,38 +362,25 @@ ForEachPing(nsIContent *content, ForEach
     return;
 
   nsCOMPtr<nsIIOService> ios = do_GetIOService();
   if (!ios)
     return;
 
   nsIDocument *doc = content->OwnerDoc();
 
-  // value contains relative URIs split on spaces (U+0020)
-  const char16_t *start = value.BeginReading();
-  const char16_t *end   = value.EndReading();
-  const char16_t *iter  = start;
-  for (;;) {
-    if (iter < end && *iter != ' ') {
-      ++iter;
-    } else {  // iter is pointing at either end or a space
-      while (*start == ' ' && start < iter)
-        ++start;
-      if (iter != start) {
-        nsCOMPtr<nsIURI> uri, baseURI = content->GetBaseURI();
-        ios->NewURI(NS_ConvertUTF16toUTF8(Substring(start, iter)),
-                    doc->GetDocumentCharacterSet().get(),
-                    baseURI, getter_AddRefs(uri));
-        if (CheckPingURI(uri, content)) {
-          callback(closure, content, uri, ios);
-        }
-      }
-      start = iter = iter + 1;
-      if (iter >= end)
-        break;
+  nsWhitespaceTokenizer tokenizer(value);
+
+  while (tokenizer.hasMoreTokens()) {
+    nsCOMPtr<nsIURI> uri, baseURI = content->GetBaseURI();
+    ios->NewURI(NS_ConvertUTF16toUTF8(tokenizer.nextToken()),
+                doc->GetDocumentCharacterSet().get(),
+                baseURI, getter_AddRefs(uri));
+    if (CheckPingURI(uri, content)) {
+      callback(closure, content, uri, ios);
     }
   }
 }
 
 //----------------------------------------------------------------------
 
 // We wait this many milliseconds before killing the ping channel...
 #define PING_TIMEOUT 10000