10 FuzzedDataProvider fdp(data, size);
11 std::string source = fdp.ConsumeRandomLengthString(256);
12 std::string source2 = fdp.ConsumeRandomLengthString(64);
21 volatile size_t length = 0;
22 length += ascii_result.size();
23 length += unicode_result.size();
29 if (!ascii_result.empty()) {
31 length += roundtrip.size();
38 std::u32string utf32_out;
41 length += utf32_out.size();
45 (void)is_valid_punycode;
48 if (punycode_ok && !utf32_out.empty()) {
49 std::string punycode_back;
50 volatile bool encode_ok =
52 length += punycode_back.size();
64 if (utf32_len > 0 && utf32_len < 1024) {
65 std::vector<char32_t> utf32_buf(utf32_len + 1, 0);
74 if (utf8_len > 0 && utf8_len < 4096) {
75 std::string utf8_back(utf8_len,
'\0');
89 std::u32string utf32_label;
91 if (ok && !utf32_label.empty()) {
97 std::u32string ascii_label(source2.begin(), source2.end());
98 if (!ascii_label.empty()) {
100 (void)ascii_label_valid;
109 std::string ascii_copy = source;
111 length += ascii_copy.size();
116 if (utf32_len > 0 && utf32_len < 256) {
117 std::u32string utf32_input(utf32_len, 0);
121 utf32_input.resize(actual);
123 length += mapped.size();
132 volatile bool has_forbidden =
137 volatile bool is_ascii_str =
148 if (utf32_len > 0 && utf32_len < 256) {
149 std::u32string utf32_input(utf32_len, 0);
153 utf32_input.resize(actual);
155 length += utf32_input.size();
173 if (!ascii_result.empty()) {
175 if (!ascii_result2.empty() && ascii_result2 != ascii_result) {
177 "IDNA to_ascii not idempotent!\n"
178 " input: %s\n first: %s\n second: %s\n",
179 source.c_str(), ascii_result.c_str(), ascii_result2.c_str());
193 if (!unicode_result.empty()) {
195 if (!unicode_result2.empty() && unicode_result2 != unicode_result) {
197 "IDNA to_unicode not idempotent!\n"
198 " input: %s\n first: %s\n second: %s\n",
199 source.c_str(), unicode_result.c_str(), unicode_result2.c_str());
214 std::string long_domain = fdp.ConsumeRandomLengthString(270);
216 length += long_ascii.size();
220 volatile bool long_dns_ok = ada::checkers::verify_dns_length(long_domain);
223 if (!long_ascii.empty()) {
224 volatile bool long_ascii_dns_ok =
225 ada::checkers::verify_dns_length(long_ascii);
226 (void)long_ascii_dns_ok;
237 std::string blob = fdp.ConsumeRandomLengthString(128);
238 std::u32string decoded;
240 if (ok && !decoded.empty()) {
241 std::string reencoded;
244 length += reencoded.size();
247 if (enc_ok && !reencoded.empty()) {
248 std::u32string redecoded;
250 if (redec_ok && redecoded != decoded) {
251 printf(
"Punycode round-trip mismatch!\n");