summaryrefslogtreecommitdiff
path: root/dom/security/nsCSPUtils.h
diff options
context:
space:
mode:
Diffstat (limited to 'dom/security/nsCSPUtils.h')
-rw-r--r--dom/security/nsCSPUtils.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/dom/security/nsCSPUtils.h b/dom/security/nsCSPUtils.h
index 84dcbb7fcc..b06f9d3c84 100644
--- a/dom/security/nsCSPUtils.h
+++ b/dom/security/nsCSPUtils.h
@@ -15,6 +15,54 @@
#include "nsUnicharUtils.h"
#include "mozilla/Logging.h"
+// ======= Defines and helper functions =======
+
+static const char16_t COLON = ':';
+static const char16_t SEMICOLON = ';';
+static const char16_t SLASH = '/';
+static const char16_t PLUS = '+';
+static const char16_t DASH = '-';
+static const char16_t DOT = '.';
+static const char16_t UNDERLINE = '_';
+static const char16_t TILDE = '~';
+static const char16_t WILDCARD = '*';
+static const char16_t SINGLEQUOTE = '\'';
+static const char16_t OPEN_CURL = '{';
+static const char16_t CLOSE_CURL = '}';
+static const char16_t NUMBER_SIGN = '#';
+static const char16_t QUESTIONMARK = '?';
+static const char16_t PERCENT_SIGN = '%';
+static const char16_t EXCLAMATION = '!';
+static const char16_t DOLLAR = '$';
+static const char16_t AMPERSAND = '&';
+static const char16_t OPENBRACE = '(';
+static const char16_t CLOSINGBRACE = ')';
+static const char16_t EQUALS = '=';
+static const char16_t ATSYMBOL = '@';
+
+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'));
+}
+
+// ============================================
+
namespace mozilla {
namespace dom {
struct CSP;