Bug 1224225: Use GetAsciiHost in CSP source matching code r=ckerschb draft
authorFrederik Braun <fbraun+gh@mozilla.com>
Wed, 15 Mar 2017 13:22:06 +0100
changeset 499926 725163deba14e014201c55fc1e5b9b040476f549
parent 499288 48006b97073128922d1f36361bca3134afabe8fe
child 499927 580339be6a5d0a2bf00ecf6dabff8d6a8ff1423d
push id49593
push userbmo:fbraun@mozilla.com
push dateThu, 16 Mar 2017 13:21:29 +0000
reviewersckerschb
bugs1224225
milestone55.0a1
Bug 1224225: Use GetAsciiHost in CSP source matching code r=ckerschb MozReview-Commit-ID: B7SwUEMiVwc
dom/security/nsCSPUtils.cpp
--- a/dom/security/nsCSPUtils.cpp
+++ b/dom/security/nsCSPUtils.cpp
@@ -266,17 +266,17 @@ CSP_ContentTypeToDirective(nsContentPoli
   return nsIContentSecurityPolicy::DEFAULT_SRC_DIRECTIVE;
 }
 
 nsCSPHostSrc*
 CSP_CreateHostSrcFromURI(nsIURI* aURI)
 {
   // Create the host first
   nsCString host;
-  aURI->GetHost(host);
+  aURI->GetAsciiHost(host);
   nsCSPHostSrc *hostsrc = new nsCSPHostSrc(NS_ConvertUTF8toUTF16(host));
 
   // Add the scheme.
   nsCString scheme;
   aURI->GetScheme(scheme);
   hostsrc->setScheme(NS_ConvertUTF8toUTF16(scheme));
 
   int32_t port;
@@ -638,17 +638,17 @@ nsCSPHostSrc::permits(nsIURI* aUri, cons
       return false;
     }
     return true;
   }
 
   // Before we can check if the host matches, we have to
   // extract the host part from aUri.
   nsAutoCString uriHost;
-  nsresult rv = aUri->GetHost(uriHost);
+  nsresult rv = aUri->GetAsciiHost(uriHost);
   NS_ENSURE_SUCCESS(rv, false);
 
   nsString decodedUriHost;
   CSP_PercentDecodeStr(NS_ConvertUTF8toUTF16(uriHost), decodedUriHost);
 
   // 4.5) host matching: Check if the allowed host starts with a wilcard.
   if (mHost.First() == '*') {
     NS_ASSERTION(mHost[1] == '.', "Second character needs to be '.' whenever host starts with '*'");