12 const uint8_t *data =
reinterpret_cast<const uint8_t *
>(buf);
14 uint32_t code_point = 0;
16 uint64_t next_pos = pos + 16;
17 if (next_pos <= len) {
20 std::memcpy(&v1, data + pos,
sizeof(uint64_t));
22 std::memcpy(&v2, data + pos +
sizeof(uint64_t),
sizeof(uint64_t));
24 if ((v & 0x8080808080808080) == 0) {
29 unsigned char byte = data[pos];
30 while (
byte < 0b10000000) {
37 if ((
byte & 0b11100000) == 0b11000000) {
42 if ((data[pos + 1] & 0b11000000) != 0b10000000) {
45 code_point = (
byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
46 if ((code_point < 0x80) || (0x7ff < code_point)) {
49 }
else if ((
byte & 0b11110000) == 0b11100000) {
54 if ((data[pos + 1] & 0b11000000) != 0b10000000) {
57 if ((data[pos + 2] & 0b11000000) != 0b10000000) {
60 code_point = (
byte & 0b00001111) << 12 |
61 (data[pos + 1] & 0b00111111) << 6 |
62 (data[pos + 2] & 0b00111111);
63 if ((code_point < 0x800) || (0xffff < code_point) ||
64 (0xd7ff < code_point && code_point < 0xe000)) {
67 }
else if ((
byte & 0b11111000) == 0b11110000) {
72 if ((data[pos + 1] & 0b11000000) != 0b10000000) {
75 if ((data[pos + 2] & 0b11000000) != 0b10000000) {
78 if ((data[pos + 3] & 0b11000000) != 0b10000000) {
82 (
byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 |
83 (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111);
84 if (code_point <= 0xffff || 0x10ffff < code_point) {
154 FuzzedDataProvider fdp(data, size);
155 std::string source = fdp.ConsumeRandomLengthString(256);
156 std::string base = fdp.ConsumeRandomLengthString(256);
160 volatile size_t length = 0;
166 if (parse_url.has_value() ^ parse_url_aggregator.has_value()) {
167 printf(
"Source used to parse: %s", source.c_str());
173 length += parse_url->get_href().size();
174 length += parse_url->get_origin().size();
177 if (parse_url_aggregator) {
178 length += parse_url_aggregator->get_href().size();
179 length += parse_url_aggregator->get_origin().size();
181 volatile bool is_parse_url_aggregator_output_valid =
false;
182 is_parse_url_aggregator_output_valid = parse_url_aggregator->validate();
184 assert(parse_url->get_protocol() == parse_url_aggregator->get_protocol());
185 assert(parse_url->get_href() == parse_url_aggregator->get_href());
186 assert(std::string(parse_url->get_hostname()) ==
187 std::string(parse_url_aggregator->get_hostname()));
188 assert(std::string(parse_url->get_pathname()) ==
189 std::string(parse_url_aggregator->get_pathname()));
190 assert(std::string(parse_url->get_search()) ==
191 std::string(parse_url_aggregator->get_search()));
192 assert(std::string(parse_url->get_hash()) ==
193 std::string(parse_url_aggregator->get_hash()));
194 assert(std::string(parse_url->get_port()) ==
195 std::string(parse_url_aggregator->get_port()));
196 assert(parse_url->get_username() ==
197 std::string(parse_url_aggregator->get_username()));
198 assert(parse_url->get_password() ==
199 std::string(parse_url_aggregator->get_password()));
200 assert(std::string(parse_url->get_host()) ==
201 std::string(parse_url_aggregator->get_host()));
208 parse_url->set_href(source);
209 parse_url_aggregator->set_href(source);
210 assert(parse_url->get_href() == parse_url_aggregator->get_href());
219 assert(copied_url.
get_href() == parse_url->get_href());
223 assigned_url = *parse_url;
224 assert(assigned_url.
get_href() == parse_url->get_href());
227 ada::url moved_url = std::move(copied_url);
228 assert(moved_url.
get_href() == parse_url->get_href());
231 if (parse_url_aggregator) {
234 assert(std::string(copied_agg.
get_href()) ==
235 std::string(parse_url_aggregator->get_href()));
239 assigned_agg = *parse_url_aggregator;
240 assert(std::string(assigned_agg.
get_href()) ==
241 std::string(parse_url_aggregator->get_href()));
245 assert(std::string(moved_agg.
get_href()) ==
246 std::string(parse_url_aggregator->get_href()));
250 move_assigned_agg = std::move(assigned_agg);
251 assert(std::string(move_assigned_agg.
get_href()) ==
252 std::string(parse_url_aggregator->get_href()));
261 out_url->set_protocol(source);
262 out_url->set_username(source);
263 out_url->set_password(source);
264 out_url->set_hostname(source);
265 out_url->set_host(source);
266 out_url->set_pathname(source);
267 out_url->set_search(source);
268 out_url->set_hash(source);
269 out_url->set_port(source);
272 length += out_url->get_protocol().size();
273 length += out_url->get_username().size();
274 length += out_url->get_password().size();
275 length += out_url->get_hostname().size();
276 length += out_url->get_host().size();
277 length += out_url->get_pathname().size();
278 length += out_url->get_search().size();
279 length += out_url->get_hash().size();
280 length += out_url->get_origin().size();
281 length += out_url->get_port().size();
282 length += out_url->get_pathname_length();
284 length += out_url->to_string().size();
287 (void)out_url->has_valid_domain();
288 (void)out_url->has_credentials();
289 (void)out_url->has_empty_hostname();
290 (void)out_url->has_hostname();
291 (void)out_url->has_port();
292 (void)out_url->has_hash();
293 (void)out_url->has_search();
294 (void)out_url->get_components();
300 auto out_aggregator =
303 if (out_aggregator) {
304 out_aggregator->set_protocol(source);
305 out_aggregator->set_username(source);
306 out_aggregator->set_password(source);
307 out_aggregator->set_hostname(source);
308 out_aggregator->set_host(source);
309 out_aggregator->set_pathname(source);
310 out_aggregator->set_search(source);
311 out_aggregator->set_hash(source);
312 out_aggregator->set_port(source);
315 length += out_aggregator->get_protocol().size();
316 length += out_aggregator->get_username().size();
317 length += out_aggregator->get_password().size();
318 length += out_aggregator->get_hostname().size();
319 length += out_aggregator->get_host().size();
320 length += out_aggregator->get_pathname().size();
321 length += out_aggregator->get_search().size();
322 length += out_aggregator->get_hash().size();
323 length += out_aggregator->get_origin().size();
324 length += out_aggregator->get_port().size();
325 length += out_aggregator->get_pathname_length();
327 length += out_aggregator->to_string().size();
329 volatile bool is_output_valid =
false;
330 is_output_valid = out_aggregator->validate();
332 (void)out_aggregator->to_diagram();
335 (void)out_aggregator->has_valid_domain();
336 (void)out_aggregator->has_credentials();
337 (void)out_aggregator->has_empty_hostname();
338 (void)out_aggregator->has_hostname();
339 (void)out_aggregator->has_non_empty_username();
340 (void)out_aggregator->has_non_empty_password();
341 (void)out_aggregator->has_password();
342 (void)out_aggregator->has_port();
343 (void)out_aggregator->has_hash();
344 (void)out_aggregator->has_search();
345 (void)out_aggregator->get_components();
348 out_aggregator->clear_port();
349 out_aggregator->clear_search();
350 out_aggregator->clear_hash();
362 length += result->get_href().size();
363 length += result->get_origin().size();
371 length += result->get_href().size();
372 length += result->get_origin().size();
384 if (res_url.has_value() ^ res_agg.has_value()) {
385 printf(
"Relative parse inconsistency for source=%s base=%s\n",
386 source.c_str(), base.c_str());
389 if (res_url && res_agg) {
390 if (res_url->get_href() != std::string(res_agg->get_href())) {
391 printf(
"Relative parse href mismatch for source=%s base=%s\n",
392 source.c_str(), base.c_str());
405 std::string input2 = fdp.ConsumeRandomLengthString(128);
408 length += level2->get_href().size();
409 volatile bool v = level2->validate();
426 length += result->get_href().size();
440 bool is_valid = ada::checkers::verify_dns_length(source);