chromium/services/network/orb/orb_sniffers.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "services/network/orb/orb_sniffers.h"

#include <stddef.h>

#include <set>
#include <string>
#include <unordered_set>
#include <vector>

#include "base/check_op.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/fixed_flat_set.h"
#include "base/lazy_instance.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "net/base/mime_sniffer.h"

namespace network::orb {

namespace {

void AdvancePastWhitespace(std::string_view* data) {}

// Returns kYes if |data| starts with one of the string patterns in
// |signatures|, kMaybe if |data| is a prefix of one of the patterns in
// |signatures|, and kNo otherwise.
//
// When kYes is returned, the matching prefix is erased from |data|.
SniffingResult MatchesSignature(std::string_view* data,
                                const std::string_view signatures[],
                                size_t arr_size,
                                base::CompareCase compare_case) {}

size_t FindFirstJavascriptLineTerminator(std::string_view hay, size_t pos) {}

// Checks if |data| starts with an HTML comment (i.e. with "<!-- ... -->").
// - If there is a valid, terminated comment then returns kYes.
// - If there is a start of a comment, but the comment is not completed (e.g.
//   |data| == "<!-" or |data| == "<!-- not terminated yet") then returns
//   kMaybe.
// - Returns kNo otherwise.
//
// Mutates |data| to advance past the comment when returning kYes.  Note that
// SingleLineHTMLCloseComment ECMAscript rule is taken into account which means
// that characters following an HTML comment are consumed up to the nearest line
// terminating character.
SniffingResult MaybeSkipHtmlComment(std::string_view* data) {}

}  // anonymous namespace

// This function is a slight modification of |net::SniffForHTML|.
SniffingResult SniffForHTML(std::string_view data) {}

SniffingResult SniffForXML(std::string_view data) {}

SniffingResult SniffForJSON(std::string_view data) {}

SniffingResult SniffForFetchOnlyResource(std::string_view data) {}

}  // namespace network::orb