#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <string_view>
#include "base/strings/string_util.h"
#include "url/url_canon.h"
#include "url/url_canon_internal.h"
#include "url/url_file.h"
#include "url/url_parse_internal.h"
namespace url {
namespace {
bool IsLocalhost(const char* spec, int begin, int end) { … }
bool IsLocalhost(const char16_t* spec, int begin, int end) { … }
template <typename CHAR>
int DoFindWindowsDriveLetter(const CHAR* spec, int begin, int end) { … }
#ifdef WIN32
template <typename CHAR>
int FileDoDriveSpec(const CHAR* spec, int begin, int end, CanonOutput* output) {
int drive_letter_pos = FindWindowsDriveLetter(spec, begin, end);
if (drive_letter_pos < begin)
return begin;
output->push_back('/');
if (base::IsAsciiLower(spec[drive_letter_pos]))
output->push_back(static_cast<char>(spec[drive_letter_pos] - 'a' + 'A'));
else
output->push_back(static_cast<char>(spec[drive_letter_pos]));
output->push_back(':');
return drive_letter_pos + 2;
}
#endif
template<typename CHAR, typename UCHAR>
bool DoFileCanonicalizePath(const CHAR* spec,
const Component& path,
CanonOutput* output,
Component* out_path) { … }
template<typename CHAR, typename UCHAR>
bool DoCanonicalizeFileURL(const URLComponentSource<CHAR>& source,
const Parsed& parsed,
CharsetConverter* query_converter,
CanonOutput* output,
Parsed* new_parsed) { … }
}
int FindWindowsDriveLetter(const char* spec, int begin, int end) { … }
int FindWindowsDriveLetter(const char16_t* spec, int begin, int end) { … }
bool CanonicalizeFileURL(const char* spec,
int spec_len,
const Parsed& parsed,
CharsetConverter* query_converter,
CanonOutput* output,
Parsed* new_parsed) { … }
bool CanonicalizeFileURL(const char16_t* spec,
int spec_len,
const Parsed& parsed,
CharsetConverter* query_converter,
CanonOutput* output,
Parsed* new_parsed) { … }
bool FileCanonicalizePath(const char* spec,
const Component& path,
CanonOutput* output,
Component* out_path) { … }
bool FileCanonicalizePath(const char16_t* spec,
const Component& path,
CanonOutput* output,
Component* out_path) { … }
bool ReplaceFileURL(const char* base,
const Parsed& base_parsed,
const Replacements<char>& replacements,
CharsetConverter* query_converter,
CanonOutput* output,
Parsed* new_parsed) { … }
bool ReplaceFileURL(const char* base,
const Parsed& base_parsed,
const Replacements<char16_t>& replacements,
CharsetConverter* query_converter,
CanonOutput* output,
Parsed* new_parsed) { … }
}