// Copyright 2013 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/350788890): Remove this and spanify to fix the errors. #pragma allow_unsafe_buffers #endif // Functions to canonicalize "standard" URLs, which are ones that have an // authority section including a host name. #include "url/url_canon.h" #include "url/url_canon_internal.h" #include "url/url_constants.h" namespace url { namespace { template <typename CHAR> bool DoCanonicalizeStandardURL(const URLComponentSource<CHAR>& source, const Parsed& parsed, SchemeType scheme_type, CharsetConverter* query_converter, CanonOutput* output, Parsed* new_parsed) { … } } // namespace // Returns the default port for the given canonical scheme, or PORT_UNSPECIFIED // if the scheme is unknown. // // Please keep blink::DefaultPortForProtocol and url::DefaultPortForProtocol in // sync. int DefaultPortForScheme(std::string_view scheme) { … } bool CanonicalizeStandardURL(const char* spec, const Parsed& parsed, SchemeType scheme_type, CharsetConverter* query_converter, CanonOutput* output, Parsed* new_parsed) { … } bool CanonicalizeStandardURL(const char16_t* spec, const Parsed& parsed, SchemeType scheme_type, CharsetConverter* query_converter, CanonOutput* output, Parsed* new_parsed) { … } // It might be nice in the future to optimize this so unchanged components don't // need to be recanonicalized. This is especially true since the common case for // ReplaceComponents is removing things we don't want, like reference fragments // and usernames. These cases can become more efficient if we can assume the // rest of the URL is OK with these removed (or only the modified parts // recanonicalized). This would be much more complex to implement, however. // // You would also need to update DoReplaceComponents in url_util.cc which // relies on this re-checking everything (see the comment there for why). bool ReplaceStandardURL(const char* base, const Parsed& base_parsed, const Replacements<char>& replacements, SchemeType scheme_type, CharsetConverter* query_converter, CanonOutput* output, Parsed* new_parsed) { … } // For 16-bit replacements, we turn all the replacements into UTF-8 so the // regular code path can be used. bool ReplaceStandardURL(const char* base, const Parsed& base_parsed, const Replacements<char16_t>& replacements, SchemeType scheme_type, CharsetConverter* query_converter, CanonOutput* output, Parsed* new_parsed) { … } } // namespace url