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 224774 0807d8ab3e5ad538bbd669aaec37ca5dbbe3554c
parent 224773 938f95281dd3ff6c1164411b6ec1f7835662d2d2
child 224775 404701fe920a1015a086715e08eb3d221270cabe
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmt, sstamm, lmandel
bugs1063730
milestone34.0a2
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
@@ -130,27 +130,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;
   }
 
   uint32_t begin = 0;