chromium/third_party/blink/renderer/core/url_pattern/url_pattern.cc

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

#include "third_party/blink/renderer/core/url_pattern/url_pattern.h"

#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "third_party/blink/public/common/safe_url_pattern.h"
#include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_urlpattern_urlpatterninit_usvstring.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_urlpatterninit_usvstring.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_url_pattern_component_result.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_url_pattern_init.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_url_pattern_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_url_pattern_result.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/url_pattern/url_pattern_canon.h"
#include "third_party/blink/renderer/core/url_pattern/url_pattern_component.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_regexp.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_to_number.h"
#include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/liburlpattern/constructor_string_parser.h"
#include "third_party/liburlpattern/pattern.h"
#include "third_party/liburlpattern/tokenize.h"
#include "third_party/liburlpattern/utils.h"

namespace blink {

Component;
ValueType;
ComponentSet;

namespace {

// Utility function to determine if a pathname is absolute or not.  For
// kURL values this mainly consists of a check for a leading slash.  For
// patterns we do some additional checking for escaped or grouped slashes.
bool IsAbsolutePathname(const String& pathname, ValueType type) {}

// Utility function to determine if the default port for the given protocol
// matches the given port number.
bool IsProtocolDefaultPort(const String& protocol, const String& port) {}

// Base URL values that include pattern string characters should not blow
// up pattern parsing.  Automatically escape them.  We must not escape inputs
// for non-pattern base URLs, though.
String EscapeBaseURLString(const String& input, ValueType type) {}

// A utility method that takes a URLPatternInit, splits it apart, and applies
// the individual component values in the given set of strings.  The strings
// are only applied if a value is present in the init structure.
void ApplyInit(const URLPatternInit* init,
               ValueType type,
               String& protocol,
               String& username,
               String& password,
               String& hostname,
               String& port,
               String& pathname,
               String& search,
               String& hash,
               ExceptionState& exception_state) {}

URLPatternComponentResult* MakeURLPatternComponentResult(
    ScriptState* script_state,
    const String& input,
    const Vector<std::pair<String, String>>& group_values) {}

URLPatternInit* MakeURLPatternInit(
    const liburlpattern::ConstructorStringParser::Result& result) {}

ComponentSet ToURLPatternComponentSet(
    const liburlpattern::ConstructorStringParser::ComponentSet&
        present_components) {}

}  // namespace

URLPattern* URLPattern::From(v8::Isolate* isolate,
                             const V8URLPatternCompatible* compatible,
                             const KURL& base_url,
                             ExceptionState& exception_state) {}

URLPattern* URLPattern::Create(v8::Isolate* isolate,
                               const V8URLPatternInput* input,
                               const String& base_url,
                               const URLPatternOptions* options,
                               ExceptionState& exception_state) {}

URLPattern* URLPattern::Create(v8::Isolate* isolate,
                               const V8URLPatternInput* input,
                               const String& base_url,
                               ExceptionState& exception_state) {}

URLPattern* URLPattern::Create(v8::Isolate* isolate,
                               const V8URLPatternInput* input,
                               const URLPatternOptions* options,
                               ExceptionState& exception_state) {}

URLPattern* URLPattern::Create(v8::Isolate* isolate,
                               const V8URLPatternInput* input,
                               ExceptionState& exception_state) {}

URLPattern* URLPattern::Create(v8::Isolate* isolate,
                               const URLPatternInit* init,
                               Component* precomputed_protocol_component,
                               const URLPatternOptions* options,
                               ExceptionState& exception_state) {}

URLPattern::URLPattern(Component* protocol,
                       Component* username,
                       Component* password,
                       Component* hostname,
                       Component* port,
                       Component* pathname,
                       Component* search,
                       Component* hash,
                       Options options,
                       base::PassKey<URLPattern> key)
    :{}

bool URLPattern::test(ScriptState* script_state,
                      const V8URLPatternInput* input,
                      const String& base_url,
                      ExceptionState& exception_state) const {}

bool URLPattern::test(ScriptState* script_state,
                      const V8URLPatternInput* input,
                      ExceptionState& exception_state) const {}

URLPatternResult* URLPattern::exec(ScriptState* script_state,
                                   const V8URLPatternInput* input,
                                   const String& base_url,
                                   ExceptionState& exception_state) const {}

URLPatternResult* URLPattern::exec(ScriptState* script_state,
                                   const V8URLPatternInput* input,
                                   ExceptionState& exception_state) const {}

String URLPattern::protocol() const {}

String URLPattern::username() const {}

String URLPattern::password() const {}

String URLPattern::hostname() const {}

String URLPattern::port() const {}

String URLPattern::pathname() const {}

String URLPattern::search() const {}

String URLPattern::hash() const {}

bool URLPattern::hasRegExpGroups() const {}

// static
int URLPattern::compareComponent(const V8URLPatternComponent& component,
                                 const URLPattern* left,
                                 const URLPattern* right) {}

std::optional<SafeUrlPattern> URLPattern::ToSafeUrlPattern(
    ExceptionState& exception_state) const {}

String URLPattern::ToString() const {}

void URLPattern::Trace(Visitor* visitor) const {}

bool URLPattern::Match(ScriptState* script_state,
                       const V8URLPatternInput* input,
                       const String& base_url,
                       URLPatternResult* result,
                       ExceptionState& exception_state) const {}

// static

}  // namespace blink