summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-04-23 14:13:58 +0000
committerMoonchild <moonchild@palemoon.org>2020-04-23 14:13:58 +0000
commiteb8a6523b811c7d3873690d67120f5ba542b7323 (patch)
tree7e85a49787bcf616939014d4d5f67fa185a7a30f
parentf2e99fecfdb1bfc31361fac6631e5dfdb5cfa616 (diff)
downloaduxp-eb8a6523b811c7d3873690d67120f5ba542b7323.tar.gz
Issue #80 - De-unify dom/security
Exception: CSPUtils relies on something in CSPContext, but on Windows it throws in an MSVC include which provides no hints.
-rw-r--r--dom/security/SRICheck.h1
-rw-r--r--dom/security/moz.build7
-rw-r--r--dom/security/nsCSPParser.h1
-rw-r--r--dom/security/nsCSPUtils.cpp27
-rw-r--r--dom/security/nsContentSecurityManager.cpp10
-rw-r--r--dom/security/nsMixedContentBlocker.cpp4
6 files changed, 47 insertions, 3 deletions
diff --git a/dom/security/SRICheck.h b/dom/security/SRICheck.h
index 82929fe36a..46de0532f1 100644
--- a/dom/security/SRICheck.h
+++ b/dom/security/SRICheck.h
@@ -9,6 +9,7 @@
#include "nsCOMPtr.h"
#include "nsICryptoHash.h"
+#include "nsString.h"
class nsIChannel;
class nsIUnicharStreamLoader;
diff --git a/dom/security/moz.build b/dom/security/moz.build
index 00f7376a85..587e1e898f 100644
--- a/dom/security/moz.build
+++ b/dom/security/moz.build
@@ -24,12 +24,15 @@ EXPORTS += [
]
UNIFIED_SOURCES += [
+ 'nsCSPContext.cpp',
+ 'nsCSPUtils.cpp',
+]
+
+SOURCES += [
'ContentVerifier.cpp',
'nsContentSecurityManager.cpp',
- 'nsCSPContext.cpp',
'nsCSPParser.cpp',
'nsCSPService.cpp',
- 'nsCSPUtils.cpp',
'nsMixedContentBlocker.cpp',
'SRICheck.cpp',
'SRIMetadata.cpp',
diff --git a/dom/security/nsCSPParser.h b/dom/security/nsCSPParser.h
index d500a1c18d..59f5d2d6d2 100644
--- a/dom/security/nsCSPParser.h
+++ b/dom/security/nsCSPParser.h
@@ -7,6 +7,7 @@
#ifndef nsCSPParser_h___
#define nsCSPParser_h___
+#include "nsCSPContext.h"
#include "nsCSPUtils.h"
#include "nsIURI.h"
#include "nsString.h"
diff --git a/dom/security/nsCSPUtils.cpp b/dom/security/nsCSPUtils.cpp
index 6d4f297d6d..e9f218c145 100644
--- a/dom/security/nsCSPUtils.cpp
+++ b/dom/security/nsCSPUtils.cpp
@@ -17,6 +17,10 @@
#include "nsIURL.h"
#include "nsReadableUtils.h"
#include "nsSandboxFlags.h"
+#include "nsString.h"
+#include "mozilla/Logging.h"
+
+using namespace mozilla;
#define DEFAULT_PORT -1
@@ -30,6 +34,29 @@ GetCspUtilsLog()
#define CSPUTILSLOG(args) MOZ_LOG(GetCspUtilsLog(), mozilla::LogLevel::Debug, args)
#define CSPUTILSLOGENABLED() MOZ_LOG_TEST(GetCspUtilsLog(), mozilla::LogLevel::Debug)
+static const char16_t PERCENT_SIGN = '%';
+
+static bool
+isCharacterToken(char16_t aSymbol)
+{
+ return (aSymbol >= 'a' && aSymbol <= 'z') ||
+ (aSymbol >= 'A' && aSymbol <= 'Z');
+}
+
+static bool
+isNumberToken(char16_t aSymbol)
+{
+ return (aSymbol >= '0' && aSymbol <= '9');
+}
+
+static bool
+isValidHexDig(char16_t aHexDig)
+{
+ return (isNumberToken(aHexDig) ||
+ (aHexDig >= 'A' && aHexDig <= 'F') ||
+ (aHexDig >= 'a' && aHexDig <= 'f'));
+}
+
void
CSP_PercentDecodeStr(const nsAString& aEncStr, nsAString& outDecStr)
{
diff --git a/dom/security/nsContentSecurityManager.cpp b/dom/security/nsContentSecurityManager.cpp
index 5c6701992f..298dc810ea 100644
--- a/dom/security/nsContentSecurityManager.cpp
+++ b/dom/security/nsContentSecurityManager.cpp
@@ -5,16 +5,26 @@
#include "nsIStreamListener.h"
#include "nsILoadInfo.h"
#include "nsIOService.h"
+#include "nsIProtocolHandler.h"
#include "nsContentUtils.h"
#include "nsCORSListenerProxy.h"
#include "nsIStreamListener.h"
+#include "nsIScriptError.h"
#include "nsCDefaultURIFixup.h"
#include "nsIURIFixup.h"
#include "nsIImageLoadingContent.h"
+#include "nsNetUtil.h"
+#include "mozilla/ArrayUtils.h"
+#include "nsString.h"
+#include "nsMimeTypes.h"
+#include "nsContentPolicyUtils.h"
+#include "nsCharSeparatedTokenizer.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/TabChild.h"
+using namespace mozilla;
+
NS_IMPL_ISUPPORTS(nsContentSecurityManager,
nsIContentSecurityManager,
nsIChannelEventSink)
diff --git a/dom/security/nsMixedContentBlocker.cpp b/dom/security/nsMixedContentBlocker.cpp
index 543429aff2..85fb06d8d7 100644
--- a/dom/security/nsMixedContentBlocker.cpp
+++ b/dom/security/nsMixedContentBlocker.cpp
@@ -20,6 +20,8 @@
#include "nsIContentViewer.h"
#include "nsIChannel.h"
#include "nsIHttpChannel.h"
+#include "nsIProtocolHandler.h"
+#include "nsIInterfaceRequestorUtils.h"
#include "nsIParentChannel.h"
#include "mozilla/Preferences.h"
#include "nsIScriptObjectPrincipal.h"
@@ -33,12 +35,12 @@
#include "nsAsyncRedirectVerifyHelper.h"
#include "mozilla/LoadInfo.h"
#include "nsISiteSecurityService.h"
+#include "nsNetUtil.h"
#include "mozilla/Logging.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/ipc/URIUtils.h"
-
using namespace mozilla;
enum nsMixedContentBlockerMessageType {