chromium/net/cookies/parsed_cookie.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Portions of this code based on Mozilla:
//   (netwerk/cookie/src/nsCookieService.cpp)
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is mozilla.org code.
 *
 * The Initial Developer of the Original Code is
 * Netscape Communications Corporation.
 * Portions created by the Initial Developer are Copyright (C) 2003
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Daniel Witte ([email protected])
 *   Michiel van Leeuwen ([email protected])
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "net/cookies/parsed_cookie.h"

#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/checked_math.h"
#include "base/strings/string_util.h"
#include "net/base/features.h"
#include "net/cookies/cookie_constants.h"
#include "net/cookies/cookie_inclusion_status.h"
#include "net/http/http_util.h"

namespace {

const char kPathTokenName[] =;
const char kDomainTokenName[] =;
const char kExpiresTokenName[] =;
const char kMaxAgeTokenName[] =;
const char kSecureTokenName[] =;
const char kHttpOnlyTokenName[] =;
const char kSameSiteTokenName[] =;
const char kPriorityTokenName[] =;
const char kPartitionedTokenName[] =;

const char kTerminator[] =;
const int kTerminatorLen =;
const char kWhitespace[] =;
const char kValueSeparator =;
const char kTokenSeparator[] =;

// Returns true if |c| occurs in |chars|
// TODO(erikwright): maybe make this take an iterator, could check for end also?
inline bool CharIsA(const char c, const char* chars) {}

// Seek the iterator to the first occurrence of |character|.
// Returns true if it hits the end, false otherwise.
inline bool SeekToCharacter(std::string::const_iterator* it,
                            const std::string::const_iterator& end,
                            const char character) {}

// Seek the iterator to the first occurrence of a character in |chars|.
// Returns true if it hit the end, false otherwise.
inline bool SeekTo(std::string::const_iterator* it,
                   const std::string::const_iterator& end,
                   const char* chars) {}
// Seek the iterator to the first occurrence of a character not in |chars|.
// Returns true if it hit the end, false otherwise.
inline bool SeekPast(std::string::const_iterator* it,
                     const std::string::const_iterator& end,
                     const char* chars) {}
inline bool SeekBackPast(std::string::const_iterator* it,
                         const std::string::const_iterator& end,
                         const char* chars) {}

// Returns the string piece within |value| that is a valid cookie value.
std::string_view ValidStringPieceForValue(const std::string& value) {}

}  // namespace

namespace net {

ParsedCookie::ParsedCookie(const std::string& cookie_line,
                           CookieInclusionStatus* status_out) {}

ParsedCookie::~ParsedCookie() = default;

bool ParsedCookie::IsValid() const {}

CookieSameSite ParsedCookie::SameSite(
    CookieSameSiteString* samesite_string) const {}

CookiePriority ParsedCookie::Priority() const {}

bool ParsedCookie::SetName(const std::string& name) {}

bool ParsedCookie::SetValue(const std::string& value) {}

bool ParsedCookie::SetPath(const std::string& path) {}

bool ParsedCookie::SetDomain(const std::string& domain) {}

bool ParsedCookie::SetExpires(const std::string& expires) {}

bool ParsedCookie::SetMaxAge(const std::string& maxage) {}

bool ParsedCookie::SetIsSecure(bool is_secure) {}

bool ParsedCookie::SetIsHttpOnly(bool is_http_only) {}

bool ParsedCookie::SetSameSite(const std::string& same_site) {}

bool ParsedCookie::SetPriority(const std::string& priority) {}

bool ParsedCookie::SetIsPartitioned(bool is_partitioned) {}

std::string ParsedCookie::ToCookieLine() const {}

// static
std::string::const_iterator ParsedCookie::FindFirstTerminator(
    const std::string& s) {}

// static
bool ParsedCookie::ParseToken(std::string::const_iterator* it,
                              const std::string::const_iterator& end,
                              std::string::const_iterator* token_start,
                              std::string::const_iterator* token_end) {}

// static
void ParsedCookie::ParseValue(std::string::const_iterator* it,
                              const std::string::const_iterator& end,
                              std::string::const_iterator* value_start,
                              std::string::const_iterator* value_end) {}

// static
std::string ParsedCookie::ParseTokenString(const std::string& token) {}

// static
std::string ParsedCookie::ParseValueString(const std::string& value) {}

// static
bool ParsedCookie::ValueMatchesParsedValue(const std::string& value) {}

// static
bool ParsedCookie::IsValidCookieName(const std::string& name) {}

// static
bool ParsedCookie::IsValidCookieValue(const std::string& value) {}

// static
bool ParsedCookie::CookieAttributeValueHasValidCharSet(
    const std::string& value) {}

// static
bool ParsedCookie::CookieAttributeValueHasValidSize(const std::string& value) {}

// static
bool ParsedCookie::IsValidCookieNameValuePair(
    const std::string& name,
    const std::string& value,
    CookieInclusionStatus* status_out) {}

// Parse all token/value pairs and populate pairs_.
void ParsedCookie::ParseTokenValuePairs(const std::string& cookie_line,
                                        CookieInclusionStatus& status_out) {}

void ParsedCookie::SetupAttributes() {}

bool ParsedCookie::SetString(size_t* index,
                             const std::string& key,
                             const std::string& untrusted_value) {}

bool ParsedCookie::SetBool(size_t* index, const std::string& key, bool value) {}

bool ParsedCookie::SetAttributePair(size_t* index,
                                    const std::string& key,
                                    const std::string& value) {}

void ParsedCookie::ClearAttributePair(size_t index) {}

}  // namespace net