diff options
author | Moonchild <moonchild@palemoon.org> | 2022-09-04 11:50:24 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-09-04 11:50:24 +0000 |
commit | 92452d76147e70960791f18a3db487ba9f73b446 (patch) | |
tree | de6f721496a1f4855043655012877c07cdafaa4d /dom/security | |
parent | 74124f150b7167b69f0f4ae6657489c5db556ad3 (diff) | |
download | uxp-92452d76147e70960791f18a3db487ba9f73b446.tar.gz |
Issue #80 - reinstated unified building for some large chunks of our code.
This should reduce compile complexity saving time and reducing linker stress.
Diffstat (limited to 'dom/security')
-rw-r--r-- | dom/security/moz.build | 7 | ||||
-rw-r--r-- | dom/security/nsCSPParser.cpp | 44 | ||||
-rw-r--r-- | dom/security/nsCSPUtils.cpp | 27 | ||||
-rw-r--r-- | dom/security/nsCSPUtils.h | 48 |
4 files changed, 50 insertions, 76 deletions
diff --git a/dom/security/moz.build b/dom/security/moz.build index a106216dc8..3f690ea498 100644 --- a/dom/security/moz.build +++ b/dom/security/moz.build @@ -23,15 +23,12 @@ 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.cpp b/dom/security/nsCSPParser.cpp index 12dcb9dc42..1012efe878 100644 --- a/dom/security/nsCSPParser.cpp +++ b/dom/security/nsCSPParser.cpp @@ -31,29 +31,6 @@ GetCspParserLog() #define CSPPARSERLOG(args) MOZ_LOG(GetCspParserLog(), mozilla::LogLevel::Debug, args) #define CSPPARSERLOGENABLED() MOZ_LOG_TEST(GetCspParserLog(), mozilla::LogLevel::Debug) -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 const uint32_t kSubHostPathCharacterCutoff = 512; static const char *const kHashSourceValidFns [] = { "sha256", "sha384", "sha512" }; @@ -158,27 +135,6 @@ nsCSPParser::~nsCSPParser() CSPPARSERLOG(("nsCSPParser::~nsCSPParser")); } -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 nsCSPParser::resetCurChar(const nsAString& aToken) { diff --git a/dom/security/nsCSPUtils.cpp b/dom/security/nsCSPUtils.cpp index 5f0bac1cd8..9459c65cf0 100644 --- a/dom/security/nsCSPUtils.cpp +++ b/dom/security/nsCSPUtils.cpp @@ -16,10 +16,6 @@ #include "nsIURL.h" #include "nsReadableUtils.h" #include "nsSandboxFlags.h" -#include "nsString.h" -#include "mozilla/Logging.h" - -using namespace mozilla; #define DEFAULT_PORT -1 @@ -33,29 +29,6 @@ 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/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; |