root/Source/platform/network/ContentSecurityPolicyParsers.cpp

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. isCSPDirectiveNameCharacter
  2. isCSPDirectiveValueCharacter
  3. isBase64EncodedCharacter
  4. isNonceCharacter
  5. isSourceCharacter
  6. isPathComponentCharacter
  7. isHostCharacter
  8. isSchemeContinuationCharacter
  9. isNotASCIISpace
  10. isNotColonOrSlash
  11. isMediaTypeCharacter

// 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

/* [<][>][^][v][top][bottom][index][help] */