Bug 1249450 part 2: Convert some nsIURI SetScheme("https") calls to use NS_GetSecureUpgradedURI instead. r=mcmanus

This commit is contained in:
Daniel Holbert
2016-03-10 15:23:46 -08:00
parent ddef67330c
commit d0cb9dfa49
2 changed files with 7 additions and 3 deletions

View File

@@ -1750,8 +1750,10 @@ HTMLFormElement::GetActionURL(nsIURI** aActionURL,
NS_ConvertUTF8toUTF16 reportSpec(spec);
// upgrade the actionURL from http:// to use https://
rv = actionURL->SetScheme(NS_LITERAL_CSTRING("https"));
nsCOMPtr<nsIURI> upgradedActionURL;
rv = NS_GetSecureUpgradedURI(actionURL, getter_AddRefs(upgradedActionURL));
NS_ENSURE_SUCCESS(rv, rv);
actionURL = upgradedActionURL.forget();
// let's log a message to the console that we are upgrading a request
nsAutoCString scheme;

View File

@@ -2174,9 +2174,11 @@ nsHttpHandler::SpeculativeConnectInternal(nsIURI *aURI,
nsCOMPtr<nsIURI> clone;
if (NS_SUCCEEDED(sss->IsSecureURI(nsISiteSecurityService::HEADER_HSTS,
aURI, flags, &isStsHost)) && isStsHost) {
if (NS_SUCCEEDED(aURI->Clone(getter_AddRefs(clone)))) {
clone->SetScheme(NS_LITERAL_CSTRING("https"));
if (NS_SUCCEEDED(NS_GetSecureUpgradedURI(aURI,
getter_AddRefs(clone)))) {
aURI = clone.get();
// (NOTE: We better make sure |clone| stays alive until the end
// of the function now, since our aURI arg now points to it!)
}
}