Bug 1094449. Treat @rel on anchors as a set of space-separated tokens, not a single token. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 21 Nov 2014 14:58:54 -0500
changeset 241275 125c6f4823e5515d9a65f152b77ed8e2510d8bbb
parent 241274 762d9365ed899c4d8f8ccd587d5d29733537defe
child 241276 276ed454c4cd4c994293003431bf3a357497a65d
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1094449
milestone36.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 1094449. Treat @rel on anchors as a set of space-separated tokens, not a single token. r=smaug
docshell/base/nsDocShell.cpp
docshell/test/bug530396-subframe.html
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -13184,22 +13184,25 @@ nsDocShell::OnLinkClickSync(nsIContent *
         }
       }
     }
   }
 
   uint32_t flags = INTERNAL_LOAD_FLAGS_NONE;
   if (IsElementAnchor(aContent)) {
     MOZ_ASSERT(aContent->IsHTML());
-    if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel,
-                              NS_LITERAL_STRING("noreferrer"),
-                              aContent->IsInHTMLDocument() ?
-                              eIgnoreCase : eCaseMatters)) {
+    nsAutoString referrer;
+    aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, referrer);
+    nsWhitespaceTokenizerTemplate<nsContentUtils::IsHTMLWhitespace> tok(referrer);
+    while (tok.hasMoreTokens()) {
+      if (tok.nextToken().LowerCaseEqualsLiteral("noreferrer")) {
         flags |= INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER |
                  INTERNAL_LOAD_FLAGS_NO_OPENER;
+        break;
+      }
     }
   }
 
   // Get the owner document of the link that was clicked, this will be
   // the document that the link is in, or the last document that the
   // link was in. From that document, we'll get the URI to use as the
   // referer, since the current URI in this docshell may be a
   // new document that we're in the process of loading.
--- a/docshell/test/bug530396-subframe.html
+++ b/docshell/test/bug530396-subframe.html
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html>
   <body onload="window.parent.onloadCount++">
-    <a href="bug530396-noref.sjs" rel="noreferrer" id="target1">bug530396-noref.sjs</a>
-    <a href="bug530396-noref.sjs?newwindow" rel="noreferrer" id="target2" target="newwindow">bug530396-noref.sjs with new window</a>
+    <a href="bug530396-noref.sjs" rel="noreferrer foo" id="target1">bug530396-noref.sjs</a>
+    <a href="bug530396-noref.sjs?newwindow" rel="nofollow noreferrer" id="target2" target="newwindow">bug530396-noref.sjs with new window</a>
   </body>
 </html>