1- /* auto-generated on 2024-01-22 09:15:53 -0500. Do not edit! */
1+ /* auto-generated on 2024-01-29 13:13:24 -0500. Do not edit! */
22/* begin file src/ada.cpp */
33#include "ada.h"
44/* begin file src/checkers.cpp */
@@ -11221,7 +11221,7 @@ ada_warn_unused std::string to_string(ada::state state) {
1122111221namespace ada {
1122211222
1122311223bool url::parse_opaque_host(std::string_view input) {
11224- ada_log("parse_opaque_host ", input, "[", input.size(), " bytes]");
11224+ ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
1122511225 if (std::any_of(input.begin(), input.end(),
1122611226 ada::unicode::is_forbidden_host_code_point)) {
1122711227 return is_valid = false;
@@ -11235,7 +11235,7 @@ bool url::parse_opaque_host(std::string_view input) {
1123511235}
1123611236
1123711237bool url::parse_ipv4(std::string_view input) {
11238- ada_log("parse_ipv4 ", input, "[", input.size(), " bytes]");
11238+ ada_log("parse_ipv4 ", input, " [", input.size(), " bytes]");
1123911239 if (input.back() == '.') {
1124011240 input.remove_suffix(1);
1124111241 }
@@ -11310,7 +11310,7 @@ bool url::parse_ipv4(std::string_view input) {
1131011310}
1131111311
1131211312bool url::parse_ipv6(std::string_view input) {
11313- ada_log("parse_ipv6 ", input, "[", input.size(), " bytes]");
11313+ ada_log("parse_ipv6 ", input, " [", input.size(), " bytes]");
1131411314
1131511315 if (input.empty()) {
1131611316 return is_valid = false;
@@ -11634,7 +11634,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) {
1163411634}
1163511635
1163611636ada_really_inline bool url::parse_host(std::string_view input) {
11637- ada_log("parse_host ", input, "[", input.size(), " bytes]");
11637+ ada_log("parse_host ", input, " [", input.size(), " bytes]");
1163811638 if (input.empty()) {
1163911639 return is_valid = false;
1164011640 } // technically unnecessary.
@@ -11686,6 +11686,8 @@ ada_really_inline bool url::parse_host(std::string_view input) {
1168611686 ada_log("parse_host to_ascii returns false");
1168711687 return is_valid = false;
1168811688 }
11689+ ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
11690+ " bytes]");
1168911691
1169011692 if (std::any_of(host.value().begin(), host.value().end(),
1169111693 ada::unicode::is_forbidden_domain_code_point)) {
@@ -11696,7 +11698,7 @@ ada_really_inline bool url::parse_host(std::string_view input) {
1169611698 // If asciiDomain ends in a number, then return the result of IPv4 parsing
1169711699 // asciiDomain.
1169811700 if (checkers::is_ipv4(host.value())) {
11699- ada_log("parse_host got ipv4", *host);
11701+ ada_log("parse_host got ipv4 ", *host);
1170011702 return parse_ipv4(host.value());
1170111703 }
1170211704
@@ -13571,7 +13573,7 @@ void url_aggregator::set_hash(const std::string_view input) {
1357113573
1357213574bool url_aggregator::set_href(const std::string_view input) {
1357313575 ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
13574- ada_log("url_aggregator::set_href ", input, "[", input.size(), " bytes]");
13576+ ada_log("url_aggregator::set_href ", input, " [", input.size(), " bytes]");
1357513577 ada::result<url_aggregator> out = ada::parse<url_aggregator>(input);
1357613578 ada_log("url_aggregator::set_href, success :", out.has_value());
1357713579
@@ -13585,7 +13587,8 @@ bool url_aggregator::set_href(const std::string_view input) {
1358513587}
1358613588
1358713589ada_really_inline bool url_aggregator::parse_host(std::string_view input) {
13588- ada_log("url_aggregator:parse_host ", input, "[", input.size(), " bytes]");
13590+ ada_log("url_aggregator:parse_host \"", input, "\" [", input.size(),
13591+ " bytes]");
1358913592 ADA_ASSERT_TRUE(validate());
1359013593 ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
1359113594 if (input.empty()) {
@@ -13635,7 +13638,7 @@ ada_really_inline bool url_aggregator::parse_host(std::string_view input) {
1363513638 update_base_hostname(input);
1363613639 if (checkers::is_ipv4(get_hostname())) {
1363713640 ada_log("parse_host fast path ipv4");
13638- return parse_ipv4(get_hostname());
13641+ return parse_ipv4(get_hostname(), true );
1363913642 }
1364013643 ada_log("parse_host fast path ", get_hostname());
1364113644 return true;
@@ -13651,6 +13654,8 @@ ada_really_inline bool url_aggregator::parse_host(std::string_view input) {
1365113654 ada_log("parse_host to_ascii returns false");
1365213655 return is_valid = false;
1365313656 }
13657+ ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
13658+ " bytes]");
1365413659
1365513660 if (std::any_of(host.value().begin(), host.value().end(),
1365613661 ada::unicode::is_forbidden_domain_code_point)) {
@@ -13660,8 +13665,8 @@ ada_really_inline bool url_aggregator::parse_host(std::string_view input) {
1366013665 // If asciiDomain ends in a number, then return the result of IPv4 parsing
1366113666 // asciiDomain.
1366213667 if (checkers::is_ipv4(host.value())) {
13663- ada_log("parse_host got ipv4", *host);
13664- return parse_ipv4(host.value());
13668+ ada_log("parse_host got ipv4 ", *host);
13669+ return parse_ipv4(host.value(), false );
1366513670 }
1366613671
1366713672 update_base_hostname(host.value());
@@ -13914,7 +13919,7 @@ bool url_aggregator::set_hostname(const std::string_view input) {
1391413919}
1391513920
1391613921[[nodiscard]] std::string ada::url_aggregator::to_string() const {
13917- ada_log("url_aggregator::to_string buffer:", buffer, "[", buffer.size(),
13922+ ada_log("url_aggregator::to_string buffer:", buffer, " [", buffer.size(),
1391813923 " bytes]");
1391913924 if (!is_valid) {
1392013925 return "null";
@@ -14013,8 +14018,8 @@ bool url_aggregator::set_hostname(const std::string_view input) {
1401314018 return checkers::verify_dns_length(get_hostname());
1401414019}
1401514020
14016- bool url_aggregator::parse_ipv4(std::string_view input) {
14017- ada_log("parse_ipv4 ", input, "[", input.size(),
14021+ bool url_aggregator::parse_ipv4(std::string_view input, bool in_place ) {
14022+ ada_log("parse_ipv4 ", input, " [", input.size(),
1401814023 " bytes], overlaps with buffer: ",
1401914024 helpers::overlaps(input, buffer) ? "yes" : "no");
1402014025 ADA_ASSERT_TRUE(validate());
@@ -14038,20 +14043,25 @@ bool url_aggregator::parse_ipv4(std::string_view input) {
1403814043 } else {
1403914044 std::from_chars_result r;
1404014045 if (is_hex) {
14046+ ada_log("parse_ipv4 trying to parse hex number");
1404114047 r = std::from_chars(input.data() + 2, input.data() + input.size(),
1404214048 segment_result, 16);
1404314049 } else if ((input.length() >= 2) && input[0] == '0' &&
1404414050 checkers::is_digit(input[1])) {
14051+ ada_log("parse_ipv4 trying to parse octal number");
1404514052 r = std::from_chars(input.data() + 1, input.data() + input.size(),
1404614053 segment_result, 8);
1404714054 } else {
14055+ ada_log("parse_ipv4 trying to parse decimal number");
1404814056 pure_decimal_count++;
1404914057 r = std::from_chars(input.data(), input.data() + input.size(),
1405014058 segment_result, 10);
1405114059 }
1405214060 if (r.ec != std::errc()) {
14061+ ada_log("parse_ipv4 parsing failed");
1405314062 return is_valid = false;
1405414063 }
14064+ ada_log("parse_ipv4 parsed ", segment_result);
1405514065 input.remove_prefix(r.ptr - input.data());
1405614066 }
1405714067 if (input.empty()) {
@@ -14076,17 +14086,22 @@ bool url_aggregator::parse_ipv4(std::string_view input) {
1407614086 }
1407714087 }
1407814088 if ((digit_count != 4) || (!input.empty())) {
14089+ ada_log("parse_ipv4 found invalid (more than 4 numbers or empty) ");
1407914090 return is_valid = false;
1408014091 }
1408114092final:
1408214093 ada_log("url_aggregator::parse_ipv4 completed ", get_href(),
1408314094 " host: ", get_host());
1408414095
1408514096 // We could also check r.ptr to see where the parsing ended.
14086- if (pure_decimal_count == 4 && !trailing_dot) {
14097+ if (in_place && pure_decimal_count == 4 && !trailing_dot) {
14098+ ada_log(
14099+ "url_aggregator::parse_ipv4 completed and was already correct in the "
14100+ "buffer");
1408714101 // The original input was already all decimal and we validated it. So we
1408814102 // don't need to do anything.
1408914103 } else {
14104+ ada_log("url_aggregator::parse_ipv4 completed and we need to update it");
1409014105 // Optimization opportunity: Get rid of unnecessary string return in ipv4
1409114106 // serializer.
1409214107 // TODO: This is likely a bug because it goes back update_base_hostname, not
@@ -14100,8 +14115,11 @@ bool url_aggregator::parse_ipv4(std::string_view input) {
1410014115}
1410114116
1410214117bool url_aggregator::parse_ipv6(std::string_view input) {
14118+ // TODO: Implement in_place optimization: we know that input points
14119+ // in the buffer, so we can just check whether the buffer is already
14120+ // well formatted.
1410314121 // TODO: Find a way to merge parse_ipv6 with url.cpp implementation.
14104- ada_log("parse_ipv6 ", input, "[", input.size(), " bytes]");
14122+ ada_log("parse_ipv6 ", input, " [", input.size(), " bytes]");
1410514123 ADA_ASSERT_TRUE(validate());
1410614124 ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
1410714125 if (input.empty()) {
@@ -14335,7 +14353,7 @@ bool url_aggregator::parse_ipv6(std::string_view input) {
1433514353}
1433614354
1433714355bool url_aggregator::parse_opaque_host(std::string_view input) {
14338- ada_log("parse_opaque_host ", input, "[", input.size(), " bytes]");
14356+ ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
1433914357 ADA_ASSERT_TRUE(validate());
1434014358 ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
1434114359 if (std::any_of(input.begin(), input.end(),
0 commit comments