summaryrefslogtreecommitdiffstats
path: root/dom/security/nsCSPUtils.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-04-23 14:13:58 +0000
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-26 10:20:05 +0200
commit5a34fb5e1da568ce9e9e8e99423d34d33d0770f9 (patch)
treebce9693b93c249ed9260bad58e6be6c744207292 /dom/security/nsCSPUtils.cpp
parent16c8dff724b32254f8075de2f57b8770d2ba3928 (diff)
downloadUXP-5a34fb5e1da568ce9e9e8e99423d34d33d0770f9.tar
UXP-5a34fb5e1da568ce9e9e8e99423d34d33d0770f9.tar.gz
UXP-5a34fb5e1da568ce9e9e8e99423d34d33d0770f9.tar.lz
UXP-5a34fb5e1da568ce9e9e8e99423d34d33d0770f9.tar.xz
UXP-5a34fb5e1da568ce9e9e8e99423d34d33d0770f9.zip
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.
Diffstat (limited to 'dom/security/nsCSPUtils.cpp')
-rw-r--r--dom/security/nsCSPUtils.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/dom/security/nsCSPUtils.cpp b/dom/security/nsCSPUtils.cpp
index 6d4f297d6..e9f218c14 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)
{