22 FuzzedDataProvider fdp(data, size);
27 uint64_t ipv4_addr = fdp.ConsumeIntegral<uint64_t>();
29 volatile size_t ipv4_len = ipv4_str.size();
33 std::array<uint16_t, 8> ipv6_addr{};
34 for (
auto& piece : ipv6_addr) {
35 piece = fdp.ConsumeIntegral<uint16_t>();
39 size_t compress = 0, compress_length = 0;
43 assert(compress_length <= 8);
45 if (compress_length > 0) {
47 assert(compress + compress_length <= 8);
51 volatile size_t ipv6_len = ipv6_str.size();
55 assert(!ipv6_str.empty());
62 std::string ip_candidate = fdp.ConsumeRandomLengthString(32);
64 if (fast_result <= 0xFFFFFFFF) {
68 if (recheck != fast_result) {
70 "try_parse_ipv4_fast round-trip failure:\n"
71 " input='%s' result=%llu canonical='%s' recheck=%llu\n",
72 ip_candidate.c_str(), (
unsigned long long)fast_result,
73 canonical.c_str(), (
unsigned long long)recheck);
81 std::string source = fdp.ConsumeRandomLengthString(128);
84 const uint8_t* sets[] = {
93 for (
const uint8_t* charset : sets) {
95 std::string encoded = ada::unicode::percent_encode(source, charset);
96 volatile size_t enc_len = encoded.size();
101 assert(encoded.size() >= source.size());
104 size_t start_idx = fdp.ConsumeIntegralInRange<
size_t>(0, source.size());
105 std::string encoded_from =
106 ada::unicode::percent_encode(source, charset, start_idx);
107 volatile size_t enf_len = encoded_from.size();
115 volatile bool c = changed;
120 assert(out.size() >= source.size());
126 std::string out =
"prefix_";
127 size_t prefix_len = out.size();
131 assert(out.size() >= prefix_len);
137 size_t pct_pos = source.find(
'%');
138 if (pct_pos != std::string::npos) {
139 std::string decoded = ada::unicode::percent_decode(source, pct_pos);
141 assert(decoded.size() <= source.size());
142 volatile size_t dec_len = decoded.size();
150 std::string encoded = ada::unicode::percent_encode(
152 size_t pct_pos = encoded.find(
'%');
153 if (pct_pos != std::string::npos) {
154 std::string decoded = ada::unicode::percent_decode(encoded, pct_pos);
157 if (source.find(
'%') == std::string::npos && decoded != source) {
159 "percent_encode/decode round-trip failure!\n"
160 " source='%s'\n encoded='%s'\n decoded='%s'\n",
161 source.c_str(), encoded.c_str(), decoded.c_str());
166 assert(encoded == source);
174 assert(idx <= source.size());
183 std::string util_input = fdp.ConsumeRandomLengthString(128);
186 volatile bool has_tn = ada::unicode::has_tabs_or_newline(util_input);
193 if (!util_input.empty()) {
194 volatile bool is_v4 = ada::checkers::is_ipv4(util_input);
197 std::string ipv4_url =
"http://" + util_input +
"/";
203 volatile bool v = parsed->validate();
210 volatile uint8_t sig = ada::checkers::path_signature(util_input);
218 volatile bool is_nwdl =
224 if (is_nwdl && !is_wdl) {
226 "is_normalized_windows_drive_letter implies is_windows_drive_letter"
227 " but got inconsistent results for '%s'\n",
234 std::string lower_copy = util_input;
235 volatile bool all_ascii =
236 ada::unicode::to_lower_ascii(lower_copy.data(), lower_copy.size());
239 assert(lower_copy.size() == util_input.size());
243 volatile bool has_forbidden =
244 ada::unicode::contains_forbidden_domain_code_point(util_input.data(),
249 volatile uint8_t forbidden_or_upper =
250 ada::unicode::contains_forbidden_domain_code_point_or_upper(
251 util_input.data(), util_input.size());
252 (void)forbidden_or_upper;
256 volatile bool dns_ok = ada::checkers::verify_dns_length(util_input);
265 if (ipv4_addr <= 0xFFFFFFFF) {
266 std::string url_str =
"http://" + ipv4_str +
"/path?q=1";
269 volatile bool v = parsed->validate();
272 std::string host = std::string(parsed->get_hostname());
281 std::string ipv6_url_str =
"http://[" + ipv6_str +
"]/path";
284 volatile bool v = parsed_ipv6->validate();
287 std::string href = std::string(parsed_ipv6->get_href());
290 printf(
"IPv6 URL re-parse failure: '%s'\n", href.c_str());
293 if (std::string(reparsed->get_href()) != href) {
294 printf(
"IPv6 URL re-parse href mismatch: '%s' vs '%s'\n", href.c_str(),
295 std::string(reparsed->get_href()).c_str());