@@ -73,8 +73,8 @@ auto map_code_points(
73
73
return result;
74
74
}
75
75
76
- auto validate (std::u32string_view label, bool use_std3_ascii_rules, bool check_hyphens,
77
- [[maybe_unused]] bool check_bidi, bool check_joiners, bool transitional_processing)
76
+ auto validate_label (std::u32string_view label, [[maybe_unused]] bool use_std3_ascii_rules, bool check_hyphens,
77
+ [[maybe_unused]] bool check_bidi, bool check_joiners, [[maybe_unused]] bool transitional_processing)
78
78
-> tl::expected<void, domain_errc> {
79
79
// / https://www.unicode.org/reports/tr46/#Validity_Criteria
80
80
@@ -92,34 +92,6 @@ auto validate(std::u32string_view label, bool use_std3_ascii_rules, bool check_h
92
92
}
93
93
}
94
94
95
- // / Criterion 4
96
- {
97
- auto it = std::find (first, last, U' .' );
98
- if (it != last) {
99
- return tl::make_unexpected (domain_errc::bad_input);
100
- }
101
- }
102
-
103
- {
104
- // / Criterion 6
105
- static const auto is_not_valid_idna_code_point = [&use_std3_ascii_rules, &transitional_processing](auto cp) {
106
- auto status = domain::map_idna_status (cp);
107
- if (use_std3_ascii_rules || (cp > 0x7eu )) {
108
- if (transitional_processing) {
109
- return status != domain::idna_status::valid;
110
- } else {
111
- return (status != domain::idna_status::valid) && (status != domain::idna_status::deviation);
112
- }
113
- }
114
- return false ;
115
- };
116
-
117
- auto it = std::find_if (first, last, is_not_valid_idna_code_point);
118
- if (it != last) {
119
- return tl::make_unexpected (domain_errc::bad_input);
120
- }
121
- }
122
-
123
95
if (check_joiners) {
124
96
// / Criterion 7
125
97
constexpr static auto is_not_contextj = [] (auto cp) {
@@ -149,14 +121,14 @@ auto idna_process(std::u32string_view domain_name, bool use_std3_ascii_rules, bo
149
121
return tl::make_unexpected (decoded.error ());
150
122
}
151
123
152
- auto validated = validate (
153
- decoded.value (), use_std3_ascii_rules, check_hyphens, check_bidi, check_joiners, false );
124
+ auto validated =
125
+ validate_label ( decoded.value (), use_std3_ascii_rules, check_hyphens, check_bidi, check_joiners, false );
154
126
if (!validated) {
155
127
return tl::make_unexpected (validated.error ());
156
128
}
157
129
} else {
158
- auto validated = validate (
159
- label, use_std3_ascii_rules, check_hyphens, check_bidi, check_joiners, transitional_processing);
130
+ auto validated = validate_label (label, use_std3_ascii_rules, check_hyphens, check_bidi, check_joiners,
131
+ transitional_processing);
160
132
if (!validated) {
161
133
return tl::make_unexpected (validated.error ());
162
134
}
@@ -229,14 +201,8 @@ auto domain_to_ascii(
229
201
return result;
230
202
}
231
203
232
- namespace {
233
- auto domain_to_unicode (std::string_view domain_name, [[maybe_unused]] bool check_hyphens,
234
- [[maybe_unused]] bool check_bidi, [[maybe_unused]] bool check_joiners,
235
- [[maybe_unused]] bool use_std3_ascii_rules,
236
- [[maybe_unused]] bool transitional_processing,
237
- [[maybe_unused]] bool *validation_error) -> tl::expected<std::string, domain_errc> {
238
- // / https://www.unicode.org/reports/tr46/#ToUnicode
239
-
204
+ auto domain_to_u8 (std::string_view domain_name, [[maybe_unused]] bool *validation_error)
205
+ -> tl::expected<std::string, domain_errc> {
240
206
auto labels = std::vector<std::string>{};
241
207
for (auto label : split (domain_name, " ." )) {
242
208
if (label.substr (0 , 4 ) == " xn--" ) {
@@ -253,10 +219,5 @@ auto domain_to_unicode(std::string_view domain_name, [[maybe_unused]] bool check
253
219
}
254
220
return join (labels, ' .' );
255
221
}
256
- } // namespace
257
-
258
- auto domain_to_u8 (std::string_view domain_name, bool *validation_error) -> tl::expected<std::string, domain_errc> {
259
- return domain_to_unicode (domain_name, false , true , true , false , false , validation_error);
260
- }
261
222
} // namespace v1
262
223
} // namespace skyr
0 commit comments