Bug 1111834 - CORS request after preflight should not follow 30x redirect. r=sicking, a=lmandel
☠☠ backed out by bcd0c508c109 ☠ ☠
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Thu, 19 Feb 2015 13:43:40 -0800
changeset 249176 24f079da662522ca8c1f4458684f162ed9d02243
parent 249175 513cff18abaa713b6927cb87bc1938a92b264c5d
child 249177 8746f7ba56c9612b12c26a846b1400e02d4f9b24
push id970
push userjryans@gmail.com
push dateTue, 10 Mar 2015 15:54:18 +0000
reviewerssicking, lmandel
bugs1111834
milestone37.0
Bug 1111834 - CORS request after preflight should not follow 30x redirect. r=sicking, a=lmandel
dom/base/Navigator.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1212,16 +1212,22 @@ Navigator::SendBeacon(const nsAString& a
   bool crossOrigin = NS_FAILED(rv);
   nsAutoCString contentType, parsedCharset;
   rv = NS_ParseContentType(mimeType, contentType, parsedCharset);
   if (crossOrigin &&
       contentType.Length() > 0 &&
       !contentType.Equals(APPLICATION_WWW_FORM_URLENCODED) &&
       !contentType.Equals(MULTIPART_FORM_DATA) &&
       !contentType.Equals(TEXT_PLAIN)) {
+
+    // we need to set the sameOriginChecker as a notificationCallback
+    // so we can tell the channel not to follow redirects
+    nsCOMPtr<nsIInterfaceRequestor> soc = nsContentUtils::SameOriginChecker();
+    channel->SetNotificationCallbacks(soc);
+
     nsCOMPtr<nsIChannel> preflightChannel;
     nsTArray<nsCString> unsafeHeaders;
     unsafeHeaders.AppendElement(NS_LITERAL_CSTRING("Content-Type"));
     rv = NS_StartCORSPreflight(channel,
                                cors,
                                principal,
                                true,
                                unsafeHeaders,