Skip to content

Changes for version 1.23.0 / ada 3.2.4 #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 45 additions & 35 deletions ada_url/ada.cpp
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -10421,6 +10421,8 @@ ADA_POP_DISABLE_WARNINGS
#include <emmintrin.h>
#endif

#include <ranges>

namespace ada::unicode {

constexpr bool is_tabs_or_newline(char c) noexcept {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -11845,15 +11849,15 @@ ada_warn_unused std::string to_string(ada::state state) {

#include <numeric>
#include <algorithm>
#include <ranges>
#include <string>
#include <string_view>

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;
}

Expand Down Expand Up @@ -12720,6 +12724,7 @@ bool url::set_href(const std::string_view input) {
/* begin file src/parser.cpp */

#include <limits>
#include <ranges>


namespace ada::parser {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -13689,6 +13694,7 @@ namespace ada {
/* end file src/url_components.cpp */
/* begin file src/url_aggregator.cpp */

#include <ranges>
#include <string>
#include <string_view>

Expand Down Expand Up @@ -13908,7 +13914,7 @@ bool url_aggregator::set_protocol(const std::string_view input) {

if (pointer != view.end() && *pointer == ':') {
return parse_scheme_with_colon<true>(
std::string_view(view.data(), pointer - view.begin() + 1));
view.substr(0, pointer - view.begin() + 1));
}
return false;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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()) {
Expand Down
36 changes: 15 additions & 21 deletions ada_url/ada.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -4115,7 +4115,6 @@ void swap(expected<T, E> &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
Expand All @@ -4131,6 +4130,7 @@ void swap(expected<T, E> &lhs,
#include <regex>
#endif // ADA_USE_UNSAFE_STD_REGEX_PROVIDER

#if ADA_INCLUDE_URL_PATTERN
namespace ada::url_pattern_regex {

template <typename T>
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -4209,6 +4209,7 @@ enum class errors : uint8_t { type_error };
#include <iostream>
#endif // ADA_TESTING

#if ADA_INCLUDE_URL_PATTERN
namespace ada {

// Important: C++20 allows us to use concept rather than `using` or `typedef
Expand Down Expand Up @@ -4312,10 +4313,9 @@ struct url_pattern_init {
std::optional<std::string> 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
Expand Down Expand Up @@ -4378,7 +4378,6 @@ tl::expected<url_pattern<regex_provider>, 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
Expand Down Expand Up @@ -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 <class result_type = ada::url_aggregator>
Expand Down Expand Up @@ -5088,6 +5084,7 @@ std::string href_from_file(std::string_view path);
#include <iostream>
#endif // ADA_TESTING

#if ADA_INCLUDE_URL_PATTERN
namespace ada {

enum class url_pattern_part_type : uint8_t {
Expand Down Expand Up @@ -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 */
Expand All @@ -5438,6 +5434,7 @@ class url_pattern {
#include <tuple>
#include <vector>

#if ADA_INCLUDE_URL_PATTERN
namespace ada {
enum class errors : uint8_t;
}
Expand Down Expand Up @@ -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 <string>
#include <string_view>
Expand Down Expand Up @@ -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
Expand All @@ -8929,6 +8924,7 @@ url_search_params_entries_iter::next() {
#include <string_view>
#include <utility>

#if ADA_INCLUDE_URL_PATTERN
namespace ada {

inline bool url_pattern_init::operator==(const url_pattern_init& other) const {
Expand Down Expand Up @@ -9397,7 +9393,7 @@ result<std::optional<url_pattern_result>> url_pattern<regex_provider>::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 */
Expand All @@ -9412,6 +9408,7 @@ result<std::optional<url_pattern_result>> url_pattern<regex_provider>::match(
#include <string_view>


#if ADA_INCLUDE_URL_PATTERN
namespace ada::url_pattern_helpers {
#ifdef ADA_TESTING
inline std::string to_string(token_type type) {
Expand Down Expand Up @@ -10488,10 +10485,9 @@ constructor_string_parser<regex_provider>::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 */
Expand All @@ -10502,14 +10498,14 @@ constructor_string_parser<regex_provider>::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
Expand All @@ -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 <variant>
Expand Down
1 change: 1 addition & 0 deletions ada_url/ada_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"},
]
Expand Down
Loading