Bug 1326154 - Fix to prevent FlyWebService from pointing to a URL with a different origin. r=djvj

--HG--
extra : rebase_source : ef7e60f1c16f3d9faaf7bf88db4b5c39699de7f9
This commit is contained in:
Ron Waisberg 2017-05-23 15:17:02 -04:00
Родитель 907fde9487
Коммит 56e5364aaf
1 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -790,14 +790,18 @@ FlyWebMDNSService::PairWithService(const nsAString& aServiceId,
} 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);