Skip to content

Commit fde6e3b

Browse files
committed
fix: always check for forbidden domain code point
1 parent c01e386 commit fde6e3b

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/unicode.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,6 @@ constexpr static uint8_t is_forbidden_domain_code_point_table[] = {
411411
}
412412
out.value().resize(length); // we possibly want to call :shrink_to_fit otherwise we use 255 bytes.
413413
out.value().shrink_to_fit();
414-
if(std::any_of(out.value().begin(), out.value().end(), ada::unicode::is_forbidden_domain_code_point)) {
415-
out = std::nullopt;
416-
return false;
417-
}
418414
#elif defined(_WIN32) && ADA_WINDOWS_TO_ASCII_FALLBACK
419415
(void)be_strict; // unused.
420416
// Fallback on the system if ICU is not available.
@@ -525,10 +521,6 @@ constexpr static uint8_t is_forbidden_domain_code_point_table[] = {
525521
}
526522
out = std::string(required_buffer_size, 0);
527523
for(size_t i = 0; i < required_buffer_size; i++) { (*out)[i] = char(ascii_buffer.get()[i]); }
528-
if(std::any_of(out.value().begin(), out.value().end(), ada::unicode::is_forbidden_domain_code_point)) {
529-
out = std::nullopt;
530-
return false;
531-
}
532524
#else
533525
(void)be_strict; // unused.
534526
out = input; // We cannot do much more for now.

src/url.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ namespace ada {
370370
return is_valid = false;
371371
}
372372

373+
if(std::any_of(host.value().begin(), host.value().end(), ada::unicode::is_forbidden_domain_code_point)) {
374+
host = std::nullopt;
375+
return is_valid = false;
376+
}
377+
373378
// If asciiDomain ends in a number, then return the result of IPv4 parsing asciiDomain.
374379
if(checkers::is_ipv4(host.value())) {
375380
ada_log("parse_host got ipv4", *host);

0 commit comments

Comments
 (0)