diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/platform/network/ContentSecurityPolicyParsers.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/platform/network/ContentSecurityPolicyParsers.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/chromium/third_party/WebKit/Source/platform/network/ContentSecurityPolicyParsers.cpp b/chromium/third_party/WebKit/Source/platform/network/ContentSecurityPolicyParsers.cpp new file mode 100644 index 00000000000..6a59e5b07a4 --- /dev/null +++ b/chromium/third_party/WebKit/Source/platform/network/ContentSecurityPolicyParsers.cpp @@ -0,0 +1,69 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" +#include "platform/network/ContentSecurityPolicyParsers.h" + +#include "wtf/ASCIICType.h" + +namespace WebCore { + +bool isCSPDirectiveNameCharacter(UChar c) +{ + return isASCIIAlphanumeric(c) || c == '-'; +} + +bool isCSPDirectiveValueCharacter(UChar c) +{ + return isASCIISpace(c) || (c >= 0x21 && c <= 0x7e); // Whitespace + VCHAR +} + +// Only checks for general Base64 encoded chars, not '=' chars since '=' is +// positional and may only appear at the end of a Base64 encoded string. +bool isBase64EncodedCharacter(UChar c) +{ + return isASCIIAlphanumeric(c) || c == '+' || c == '/'; +} + +bool isNonceCharacter(UChar c) +{ + return isBase64EncodedCharacter(c) || c == '='; +} + +bool isSourceCharacter(UChar c) +{ + return !isASCIISpace(c); +} + +bool isPathComponentCharacter(UChar c) +{ + return c != '?' && c != '#'; +} + +bool isHostCharacter(UChar c) +{ + return isASCIIAlphanumeric(c) || c == '-'; +} + +bool isSchemeContinuationCharacter(UChar c) +{ + return isASCIIAlphanumeric(c) || c == '+' || c == '-' || c == '.'; +} + +bool isNotASCIISpace(UChar c) +{ + return !isASCIISpace(c); +} + +bool isNotColonOrSlash(UChar c) +{ + return c != ':' && c != '/'; +} + +bool isMediaTypeCharacter(UChar c) +{ + return !isASCIISpace(c) && c != '/'; +} + +} // namespace |