From bc959c29daff5c7407c1c287e4e368c6cf68e828 Mon Sep 17 00:00:00 2001 From: Bo Bayles Date: Mon, 28 Apr 2025 11:21:30 -0500 Subject: [PATCH 1/2] Upgrade to ada 3.2.4 --- ada_url/ada.cpp | 80 +++++++++++++++++++++++++++---------------------- ada_url/ada.h | 36 ++++++++++------------ pyproject.toml | 2 +- 3 files changed, 61 insertions(+), 57 deletions(-) diff --git a/ada_url/ada.cpp b/ada_url/ada.cpp index 854def2..d4f228e 100644 --- a/ada_url/ada.cpp +++ b/ada_url/ada.cpp @@ -1,4 +1,4 @@ -/* auto-generated on 2025-03-30 13:24:42 -0400. Do not edit! */ +/* auto-generated on 2025-04-28 12:16:36 -0400. Do not edit! */ /* begin file src/ada.cpp */ #include "ada.h" /* begin file src/checkers.cpp */ @@ -56,8 +56,8 @@ ada_really_inline constexpr bool is_ipv4(std::string_view view) noexcept { } // We have 0x followed by some characters, we need to check that they are // hexadecimals. - return std::all_of(view.begin() + 2, view.end(), - ada::unicode::is_lowercase_hex); + view.remove_prefix(2); + return std::ranges::all_of(view, ada::unicode::is_lowercase_hex); } // for use with path_signature, we include all characters that need percent @@ -10421,6 +10421,8 @@ ADA_POP_DISABLE_WARNINGS #include #endif +#include + namespace ada::unicode { constexpr bool is_tabs_or_newline(char c) noexcept { @@ -10461,8 +10463,7 @@ ada_really_inline bool has_tabs_or_newline( std::string_view user_input) noexcept { // first check for short strings in which case we do it naively. if (user_input.size() < 16) { // slow path - return std::any_of(user_input.begin(), user_input.end(), - is_tabs_or_newline); + return std::ranges::any_of(user_input, is_tabs_or_newline); } // fast path for long strings (expected to be common) size_t i = 0; @@ -10500,8 +10501,7 @@ ada_really_inline bool has_tabs_or_newline( std::string_view user_input) noexcept { // first check for short strings in which case we do it naively. if (user_input.size() < 16) { // slow path - return std::any_of(user_input.begin(), user_input.end(), - is_tabs_or_newline); + return std::ranges::any_of(user_input, is_tabs_or_newline); } // fast path for long strings (expected to be common) size_t i = 0; @@ -10832,10 +10832,9 @@ bool percent_encode(const std::string_view input, const uint8_t character_set[], std::string& out) { ada_log("percent_encode ", input, " to output string while ", append ? "appending" : "overwriting"); - auto pointer = - std::find_if(input.begin(), input.end(), [character_set](const char c) { - return character_sets::bit_at(character_set, c); - }); + auto pointer = std::ranges::find_if(input, [character_set](const char c) { + return character_sets::bit_at(character_set, c); + }); ada_log("percent_encode done checking, moved to ", std::distance(input.begin(), pointer)); @@ -11636,15 +11635,20 @@ ada_really_inline void parse_prepared_path(std::string_view input, // Note: input cannot be empty, it must at least contain one character ('.') // Note: we know that '\' is not present. if (input[0] != '.') { - size_t slashdot = input.find("/."); - if (slashdot == std::string_view::npos) { // common case - trivial_path = true; - } else { // uncommon - // only three cases matter: /./, /.. or a final / - trivial_path = - !(slashdot + 2 == input.size() || input[slashdot + 2] == '.' || - input[slashdot + 2] == '/'); + size_t slashdot = 0; + bool dot_is_file = true; + for (;;) { + slashdot = input.find("/.", slashdot); + if (slashdot == std::string_view::npos) { // common case + break; + } else { // uncommon + // only three cases matter: /./, /.. or a final / + slashdot += 2; + dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' || + input[slashdot] == '/'); + } } + trivial_path = dot_is_file; } } if (trivial_path) { @@ -11845,6 +11849,7 @@ ada_warn_unused std::string to_string(ada::state state) { #include #include +#include #include #include @@ -11852,8 +11857,7 @@ namespace ada { bool url::parse_opaque_host(std::string_view input) { ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]"); - if (std::ranges::any_of(input.begin(), input.end(), - ada::unicode::is_forbidden_host_code_point)) { + if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) { return is_valid = false; } @@ -12720,6 +12724,7 @@ bool url::set_href(const std::string_view input) { /* begin file src/parser.cpp */ #include +#include namespace ada::parser { @@ -13339,7 +13344,7 @@ result_type parse_url_impl(std::string_view user_input, // to optimize it. if (view.ends_with(' ')) { std::string modified_view = - std::string(view.begin(), view.end() - 1) + "%20"; + std::string(view.substr(0, view.size() - 1)) + "%20"; url.update_base_pathname(unicode::percent_encode( modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE)); } else { @@ -13689,6 +13694,7 @@ namespace ada { /* end file src/url_components.cpp */ /* begin file src/url_aggregator.cpp */ +#include #include #include @@ -13908,7 +13914,7 @@ bool url_aggregator::set_protocol(const std::string_view input) { if (pointer != view.end() && *pointer == ':') { return parse_scheme_with_colon( - std::string_view(view.data(), pointer - view.begin() + 1)); + view.substr(0, pointer - view.begin() + 1)); } return false; } @@ -14170,8 +14176,8 @@ ada_really_inline bool url_aggregator::parse_host(std::string_view input) { ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(), " bytes]"); - if (std::any_of(host.value().begin(), host.value().end(), - ada::unicode::is_forbidden_domain_code_point)) { + if (std::ranges::any_of(host.value(), + ada::unicode::is_forbidden_domain_code_point)) { return is_valid = false; } @@ -14863,8 +14869,7 @@ bool url_aggregator::parse_opaque_host(std::string_view input) { ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]"); ADA_ASSERT_TRUE(validate()); ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer)); - if (std::any_of(input.begin(), input.end(), - ada::unicode::is_forbidden_host_code_point)) { + if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) { return is_valid = false; } @@ -15093,15 +15098,20 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) { // Note: input cannot be empty, it must at least contain one character ('.') // Note: we know that '\' is not present. if (input[0] != '.') { - size_t slashdot = input.find("/."); - if (slashdot == std::string_view::npos) { // common case - trivial_path = true; - } else { // uncommon - // only three cases matter: /./, /.. or a final / - trivial_path = - !(slashdot + 2 == input.size() || input[slashdot + 2] == '.' || - input[slashdot + 2] == '/'); + size_t slashdot = 0; + bool dot_is_file = true; + for (;;) { + slashdot = input.find("/.", slashdot); + if (slashdot == std::string_view::npos) { // common case + break; + } else { // uncommon + // only three cases matter: /./, /.. or a final / + slashdot += 2; + dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' || + input[slashdot] == '/'); + } } + trivial_path = dot_is_file; } } if (trivial_path && is_at_path()) { diff --git a/ada_url/ada.h b/ada_url/ada.h index 821066a..d1a6150 100644 --- a/ada_url/ada.h +++ b/ada_url/ada.h @@ -1,4 +1,4 @@ -/* auto-generated on 2025-03-30 13:24:42 -0400. Do not edit! */ +/* auto-generated on 2025-04-28 12:16:36 -0400. Do not edit! */ /* begin file include/ada.h */ /** * @file ada.h @@ -4115,7 +4115,6 @@ void swap(expected &lhs, #endif /* end file include/ada/expected.h */ -#if ADA_INCLUDE_URL_PATTERN /* begin file include/ada/url_pattern_regex.h */ /** * @file url_search_params.h @@ -4131,6 +4130,7 @@ void swap(expected &lhs, #include #endif // ADA_USE_UNSAFE_STD_REGEX_PROVIDER +#if ADA_INCLUDE_URL_PATTERN namespace ada::url_pattern_regex { template @@ -4175,7 +4175,7 @@ class std_regex_provider final { #endif // ADA_USE_UNSAFE_STD_REGEX_PROVIDER } // namespace ada::url_pattern_regex - +#endif // ADA_INCLUDE_URL_PATTERN #endif // ADA_URL_PATTERN_REGEX_H /* end file include/ada/url_pattern_regex.h */ /* begin file include/ada/url_pattern_init.h */ @@ -4209,6 +4209,7 @@ enum class errors : uint8_t { type_error }; #include #endif // ADA_TESTING +#if ADA_INCLUDE_URL_PATTERN namespace ada { // Important: C++20 allows us to use concept rather than `using` or `typedef @@ -4312,10 +4313,9 @@ struct url_pattern_init { std::optional base_url{}; }; } // namespace ada - +#endif // ADA_INCLUDE_URL_PATTERN #endif // ADA_URL_PATTERN_INIT_H /* end file include/ada/url_pattern_init.h */ -#endif // ADA_INCLUDE_URL_PATTERN /** * @private @@ -4378,7 +4378,6 @@ tl::expected, errors> parse_url_pattern_impl( #ifndef ADA_PARSER_INL_H #define ADA_PARSER_INL_H -#if ADA_INCLUDE_URL_PATTERN /* begin file include/ada/url_pattern.h */ /** * @file url_pattern.h @@ -5014,9 +5013,6 @@ inline std::ostream &operator<<(std::ostream &out, const ada::url &u); #endif // ADA_URL_H /* end file include/ada/url.h */ -#if ADA_INCLUDE_URL_PATTERN -#endif // ADA_INCLUDE_URL_PATTERN - namespace ada { template @@ -5088,6 +5084,7 @@ std::string href_from_file(std::string_view path); #include #endif // ADA_TESTING +#if ADA_INCLUDE_URL_PATTERN namespace ada { enum class url_pattern_part_type : uint8_t { @@ -5420,9 +5417,8 @@ class url_pattern { */ bool ignore_case_ = false; }; - } // namespace ada - +#endif // ADA_INCLUDE_URL_PATTERN #endif /* end file include/ada/url_pattern.h */ /* begin file include/ada/url_pattern_helpers.h */ @@ -5438,6 +5434,7 @@ class url_pattern { #include #include +#if ADA_INCLUDE_URL_PATTERN namespace ada { enum class errors : uint8_t; } @@ -5769,10 +5766,9 @@ std::string generate_segment_wildcard_regexp( url_pattern_compile_component_options options); } // namespace ada::url_pattern_helpers - +#endif // ADA_INCLUDE_URL_PATTERN #endif /* end file include/ada/url_pattern_helpers.h */ -#endif // ADA_INCLUDE_URL_PATTERN #include #include @@ -8915,7 +8911,6 @@ url_search_params_entries_iter::next() { #endif // ADA_URL_SEARCH_PARAMS_INL_H /* end file include/ada/url_search_params-inl.h */ -#if ADA_INCLUDE_URL_PATTERN /* begin file include/ada/url_pattern-inl.h */ /** * @file url_pattern-inl.h @@ -8929,6 +8924,7 @@ url_search_params_entries_iter::next() { #include #include +#if ADA_INCLUDE_URL_PATTERN namespace ada { inline bool url_pattern_init::operator==(const url_pattern_init& other) const { @@ -9397,7 +9393,7 @@ result> url_pattern::match( } } // namespace ada - +#endif // ADA_INCLUDE_URL_PATTERN #endif /* end file include/ada/url_pattern-inl.h */ /* begin file include/ada/url_pattern_helpers-inl.h */ @@ -9412,6 +9408,7 @@ result> url_pattern::match( #include +#if ADA_INCLUDE_URL_PATTERN namespace ada::url_pattern_helpers { #ifdef ADA_TESTING inline std::string to_string(token_type type) { @@ -10488,10 +10485,9 @@ constructor_string_parser::parse(std::string_view input) { } } // namespace ada::url_pattern_helpers - +#endif // ADA_INCLUDE_URL_PATTERN #endif /* end file include/ada/url_pattern_helpers-inl.h */ -#endif // ADA_INCLUDE_URL_PATTERN // Public API /* begin file include/ada/ada_version.h */ @@ -10502,14 +10498,14 @@ constructor_string_parser::parse(std::string_view input) { #ifndef ADA_ADA_VERSION_H #define ADA_ADA_VERSION_H -#define ADA_VERSION "3.2.2" +#define ADA_VERSION "3.2.4" namespace ada { enum { ADA_VERSION_MAJOR = 3, ADA_VERSION_MINOR = 2, - ADA_VERSION_REVISION = 2, + ADA_VERSION_REVISION = 4, }; } // namespace ada @@ -10523,8 +10519,6 @@ enum { #ifndef ADA_IMPLEMENTATION_INL_H #define ADA_IMPLEMENTATION_INL_H -#if ADA_INCLUDE_URL_PATTERN -#endif // ADA_INCLUDE_URL_PATTERN #include diff --git a/pyproject.toml b/pyproject.toml index 7e64100..a539091 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ada-url" -version = "1.22.0" +version = "1.23.0" authors = [ {name = "Bo Bayles", email = "bo@bbayles.com"}, ] From eeb39f1cd57eb43e59aa93fc9869c0af4e8d0d44 Mon Sep 17 00:00:00 2001 From: Bo Bayles Date: Mon, 28 Apr 2025 11:33:02 -0500 Subject: [PATCH 2/2] Set ADA_INCLUDE_URL_PATTERN to 0 --- ada_url/ada_build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ada_url/ada_build.py b/ada_url/ada_build.py index 35a9f9e..35b5f7d 100644 --- a/ada_url/ada_build.py +++ b/ada_url/ada_build.py @@ -9,6 +9,7 @@ ada_obj = Extension( 'ada', + define_macros=[('ADA_INCLUDE_URL_PATTERN', '0')], language="c++", sources=['ada_url/ada.cpp'], include_dirs=[file_dir],