Bug 1326154 - Fix to prevent FlyWebService from pointing to a URL with a different origin. r=djvj
authorRon Waisberg <ron.waisberg@gmail.com>
Tue, 23 May 2017 15:17:02 -0400
changeset 360322 cbae2c2731e4
parent 360321 f5a0a69abe4b
child 360323 f9b2d4a39bc3
push id31874
push userarchaeopteryx@coole-files.de
push dateWed, 24 May 2017 09:25:22 +0000
treeherdermozilla-central@291a11111bdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdjvj
bugs1326154
milestone55.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 1326154 - Fix to prevent FlyWebService from pointing to a URL with a different origin. r=djvj
dom/flyweb/FlyWebService.cpp
--- a/dom/flyweb/FlyWebService.cpp
+++ b/dom/flyweb/FlyWebService.cpp
@@ -785,24 +785,28 @@ FlyWebMDNSService::PairWithService(const
   DiscoveredInfo* discInfo = mServiceMap.Get(aServiceId);
 
   nsAutoString url;
   if (discInfo->mService.mCert.IsEmpty()) {
     url.AssignLiteral("http://");
   } else {
     url.AssignLiteral("https://");
   }
-  url.Append(aInfo->mService.mHostname + NS_LITERAL_STRING("/"));
+  url.Append(aInfo->mService.mHostname);
+  if (!discInfo->mService.mPath.IsEmpty()) {
+    if (discInfo->mService.mPath.Find("/") != 0) {
+      url.Append(NS_LITERAL_STRING("/"));
+    }
+    url.Append(discInfo->mService.mPath);
+  } else {
+    url.Append(NS_LITERAL_STRING("/"));
+  }
   nsCOMPtr<nsIURI> uiURL;
   NS_NewURI(getter_AddRefs(uiURL), url);
   MOZ_ASSERT(uiURL);
-  if (!discInfo->mService.mPath.IsEmpty()) {
-    nsCOMPtr<nsIURI> tmp = uiURL.forget();
-    NS_NewURI(getter_AddRefs(uiURL), discInfo->mService.mPath, nullptr, tmp);
-  }
   if (uiURL) {
     nsAutoCString spec;
     uiURL->GetSpec(spec);
     CopyUTF8toUTF16(spec, aInfo->mService.mUiUrl);
   }
 
   aInfo->mService.mDiscoveredService = discInfo->mService;
   aInfo->mDNSServiceInfo = discInfo->mDNSServiceInfo;