Bug 1063730 - Require HTTPS for Screen/window sharing. r=mt,sstamm a=lmandel
authorEKR <ekr@rtfm.com>
Wed, 10 Sep 2014 15:01:44 -0700
changeset 216712 a706b85f6d4d
parent 216711 c43d3d833973
child 216713 e3fe616ef9a2
push id3887
push userrjesup@wgate.com
push date2014-09-12 19:33 +0000
treeherdermozilla-beta@a706b85f6d4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmt, sstamm, lmandel
bugs1063730
milestone33.0
Bug 1063730 - Require HTTPS for Screen/window sharing. r=mt,sstamm a=lmandel
dom/media/MediaManager.cpp
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -129,27 +129,37 @@ HostInDomain(const nsCString &aHost, con
 
   nsDependentCString hostRoot(aHost, hostOffset);
   return hostRoot.EqualsIgnoreCase(aPattern.BeginReading() + patternOffset);
 }
 
 static bool
 HostHasPermission(nsIURI &docURI)
 {
+  nsresult rv;
+
+  bool isHttps;
+  rv = docURI.SchemeIs("https",&isHttps);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return false;
+  }
+  if (!isHttps) {
+    return false;
+  }
+
   nsAdoptingCString hostName;
   docURI.GetAsciiHost(hostName); //normalize UTF8 to ASCII equivalent
   nsAdoptingCString domainWhiteList =
     Preferences::GetCString("media.getusermedia.screensharing.allowed_domains");
   domainWhiteList.StripWhitespace();
 
   if (domainWhiteList.IsEmpty() || hostName.IsEmpty()) {
     return false;
   }
 
-  nsresult rv;
   // Get UTF8 to ASCII domain name normalization service
   nsCOMPtr<nsIIDNService> idnService
     = do_GetService("@mozilla.org/network/idn-service;1", &rv);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return false;
   }
 
   PRUint32 begin = 0;