chromium/components/url_formatter/spoof_checks/idn_spoof_checker.cc

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

#include "components/url_formatter/spoof_checks/idn_spoof_checker.h"

#include <bit>
#include <cstdint>
#include <string_view>

#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_local_storage.h"
#include "build/build_config.h"
#include "net/base/lookup_string_in_fixed_set.h"
#include "third_party/icu/source/common/unicode/schriter.h"
#include "third_party/icu/source/common/unicode/unistr.h"
#include "third_party/icu/source/i18n/unicode/regex.h"
#include "third_party/icu/source/i18n/unicode/translit.h"
#include "third_party/icu/source/i18n/unicode/uspoof.h"
#include "url/url_features.h"

namespace url_formatter {

namespace {

class TopDomainPreloadDecoder : public net::extras::PreloadDecoder {};

// Stores whole-script-confusable information about a written script.
// Used to populate a list of WholeScriptConfusable structs.
struct WholeScriptConfusableData {};

void OnThreadTermination(void* regex_matcher) {}

base::ThreadLocalStorage::Slot& DangerousPatternTLS() {}

// Allow middle dot (U+00B7) only on Catalan domains when between two 'l's, to
// permit the Catalan character ela geminada to be expressed.
// See https://tools.ietf.org/html/rfc5892#appendix-A.3 for details.
bool HasUnsafeMiddleDot(const icu::UnicodeString& label_string,
                        std::string_view top_level_domain) {}

bool IsSubdomainOf(std::u16string_view hostname,
                   const std::u16string& top_domain) {}

#include "components/url_formatter/spoof_checks/top_domains/domains-trie-inc.cc"

// All the domains in the above file have 4 or fewer labels.
const size_t kNumberOfLabelsToCheck =;

IDNSpoofChecker::HuffmanTrieParams g_trie_params{};

// Allow these common words that are whole script confusables. They aren't
// confusable with any words in Latin scripts.
const char16_t* kAllowedWholeScriptConfusableWords[] =;

}  // namespace

IDNSpoofChecker::WholeScriptConfusable::WholeScriptConfusable(
    std::unique_ptr<icu::UnicodeSet> arg_all_letters,
    std::unique_ptr<icu::UnicodeSet> arg_latin_lookalike_letters,
    const std::vector<std::string>& arg_allowed_tlds)
    :{}

IDNSpoofChecker::WholeScriptConfusable::~WholeScriptConfusable() = default;

IDNSpoofChecker::IDNSpoofChecker() {}

IDNSpoofChecker::~IDNSpoofChecker() {}

IDNSpoofChecker::Result IDNSpoofChecker::SafeToDisplayAsUnicode(
    std::u16string_view label,
    std::string_view top_level_domain,
    std::u16string_view top_level_domain_unicode) {}

TopDomainEntry IDNSpoofChecker::GetSimilarTopDomain(
    std::u16string_view hostname) {}

Skeletons IDNSpoofChecker::GetSkeletons(std::u16string_view hostname) const {}

TopDomainEntry IDNSpoofChecker::LookupSkeletonInTopDomains(
    const std::string& skeleton,
    SkeletonType skeleton_type) {}

std::u16string IDNSpoofChecker::MaybeRemoveDiacritics(
    const std::u16string& hostname) {}

IDNA2008DeviationCharacter IDNSpoofChecker::GetDeviationCharacter(
    std::u16string_view hostname) const {}

void IDNSpoofChecker::SetAllowedUnicodeSet(UErrorCode* status) {}

bool IDNSpoofChecker::IsDigitLookalike(const icu::UnicodeString& label) {}

// static
bool IDNSpoofChecker::IsWholeScriptConfusableAllowedForTLD(
    const WholeScriptConfusable& script,
    std::string_view tld,
    std::u16string_view tld_unicode) {}

// static
bool IDNSpoofChecker::IsLabelWholeScriptConfusableForScript(
    const WholeScriptConfusable& script,
    const icu::UnicodeString& label) {}

// static
void IDNSpoofChecker::SetTrieParamsForTesting(
    const HuffmanTrieParams& trie_params) {}

// static
void IDNSpoofChecker::RestoreTrieParamsForTesting() {}

}  // namespace url_formatter