tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

CookiePrefixes.h (1141B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef mozilla_net_CookiePrefixes_h
      7 #define mozilla_net_CookiePrefixes_h
      8 
      9 #include "mozilla/net/NeckoChannelParams.h"
     10 
     11 namespace mozilla::net {
     12 
     13 class CookiePrefixes final {
     14 public:
     15  enum Prefix {
     16    eSecure,
     17    eHttp,
     18    eHost,
     19    eHostHttp,
     20  };
     21 
     22  // Returns true if `aString` begins with the `aPrefix` string.
     23  static bool Has(Prefix aPrefix, const nsAString& aString);
     24 
     25  // Returns true if `aString` begins with one of the supported prefixes.
     26  static bool Has(const nsACString& aString);
     27 
     28  // Reject cookies whose name starts with the magic prefixes from
     29  // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis
     30  // if they do not meet the criteria required by the prefix.
     31  static bool Check(const CookieStruct& aCookieData, bool aSecureRequest);
     32 };
     33 
     34 }  // namespace mozilla::net
     35 
     36 #endif  // mozilla_net_CookiePrefixes_h