Skip to content

Commit 5ab7c4c

Browse files
deps: update ada to 3.1.0
PR-URL: #57083 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 8d10bc7 commit 5ab7c4c

File tree

2 files changed

+115
-10
lines changed

2 files changed

+115
-10
lines changed

deps/ada/ada.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on 2025-01-30 18:48:55 -0500. Do not edit! */
1+
/* auto-generated on 2025-02-11 09:47:50 -0500. Do not edit! */
22
/* begin file src/ada.cpp */
33
#include "ada.h"
44
/* begin file src/checkers.cpp */

deps/ada/ada.h

+114-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on 2025-01-30 18:48:55 -0500. Do not edit! */
1+
/* auto-generated on 2025-02-11 09:47:50 -0500. Do not edit! */
22
/* begin file include/ada.h */
33
/**
44
* @file ada.h
@@ -1219,6 +1219,7 @@ constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept;
12191219
#endif // ADA_SCHEME_H
12201220
/* end file include/ada/scheme.h */
12211221

1222+
#include <string>
12221223
#include <string_view>
12231224

12241225
namespace ada {
@@ -1352,6 +1353,7 @@ struct url_base {
13521353
#endif
13531354
/* end file include/ada/url_base.h */
13541355

1356+
#include <string>
13551357
#include <string_view>
13561358
#include <optional>
13571359

@@ -4118,6 +4120,9 @@ void swap(expected<T, E> &lhs,
41184120
#ifndef ADA_URL_PATTERN_REGEX_H
41194121
#define ADA_URL_PATTERN_REGEX_H
41204122

4123+
#include <string>
4124+
#include <string_view>
4125+
41214126
#ifdef ADA_USE_UNSAFE_STD_REGEX_PROVIDER
41224127
#include <regex>
41234128
#endif // ADA_USE_UNSAFE_STD_REGEX_PROVIDER
@@ -4216,7 +4221,9 @@ concept url_pattern_encoding_callback = requires(F f, std::string_view sv) {
42164221
// either a string or a URLPatternInit struct. If a string is given,
42174222
// it will be parsed to create a URLPatternInit. The URLPatternInit
42184223
// API is defined as part of the URLPattern specification.
4224+
// All provided strings must be valid UTF-8.
42194225
struct url_pattern_init {
4226+
// All strings must be valid UTF-8.
42204227
// @see https://urlpattern.spec.whatwg.org/#process-a-urlpatterninit
42214228
static tl::expected<url_pattern_init, errors> process(
42224229
url_pattern_init init, std::string_view type,
@@ -4276,15 +4283,23 @@ struct url_pattern_init {
42764283
#endif // ADA_TESTING
42774284

42784285
bool operator==(const url_pattern_init&) const;
4279-
4286+
// If present, must be valid UTF-8.
42804287
std::optional<std::string> protocol{};
4288+
// If present, must be valid UTF-8.
42814289
std::optional<std::string> username{};
4290+
// If present, must be valid UTF-8.
42824291
std::optional<std::string> password{};
4292+
// If present, must be valid UTF-8.
42834293
std::optional<std::string> hostname{};
4294+
// If present, must be valid UTF-8.
42844295
std::optional<std::string> port{};
4296+
// If present, must be valid UTF-8.
42854297
std::optional<std::string> pathname{};
4298+
// If present, must be valid UTF-8.
42864299
std::optional<std::string> search{};
4300+
// If present, must be valid UTF-8.
42874301
std::optional<std::string> hash{};
4302+
// If present, must be valid UTF-8.
42884303
std::optional<std::string> base_url{};
42894304
};
42904305
} // namespace ada
@@ -4366,6 +4381,7 @@ tl::expected<url_pattern<regex_provider>, errors> parse_url_pattern_impl(
43664381
#ifndef ADA_IMPLEMENTATION_H
43674382
#define ADA_IMPLEMENTATION_H
43684383

4384+
#include <string>
43694385
#include <string_view>
43704386
#include <optional>
43714387

@@ -4379,6 +4395,7 @@ tl::expected<url_pattern<regex_provider>, errors> parse_url_pattern_impl(
43794395

43804396
#include <algorithm>
43814397
#include <optional>
4398+
#include <ostream>
43824399
#include <string>
43834400
#include <string_view>
43844401

@@ -5040,7 +5057,9 @@ std::string href_from_file(std::string_view path);
50405057
#endif // ADA_IMPLEMENTATION_H
50415058
/* end file include/ada/implementation.h */
50425059

5060+
#include <ostream>
50435061
#include <string>
5062+
#include <string_view>
50445063
#include <unordered_map>
50455064
#include <variant>
50465065
#include <vector>
@@ -5219,6 +5238,8 @@ class url_pattern_component {
52195238
bool has_regexp_groups = false;
52205239
};
52215240

5241+
// A URLPattern input can be either a string or a URLPatternInit object.
5242+
// If it is a string, it must be a valid UTF-8 string.
52225243
using url_pattern_input = std::variant<std::string_view, url_pattern_init>;
52235244

52245245
// A struct providing the URLPattern matching results for all
@@ -5251,19 +5272,24 @@ struct url_pattern_options {
52515272
// defined in https://wicg.github.io/urlpattern.
52525273
// More information about the URL Pattern syntax can be found at
52535274
// https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API
5275+
//
5276+
// We require all strings to be valid UTF-8: it is the user's responsibility
5277+
// to ensure that the provided strings are valid UTF-8.
52545278
template <url_pattern_regex::regex_concept regex_provider>
52555279
class url_pattern {
52565280
public:
52575281
url_pattern() = default;
52585282

52595283
/**
5284+
* If non-null, base_url must pointer at a valid UTF-8 string.
52605285
* @see https://urlpattern.spec.whatwg.org/#dom-urlpattern-exec
52615286
*/
52625287
result<std::optional<url_pattern_result>> exec(
52635288
const url_pattern_input& input,
52645289
const std::string_view* base_url = nullptr);
52655290

52665291
/**
5292+
* If non-null, base_url must pointer at a valid UTF-8 string.
52675293
* @see https://urlpattern.spec.whatwg.org/#dom-urlpattern-test
52685294
*/
52695295
result<bool> test(const url_pattern_input& input,
@@ -5725,6 +5751,7 @@ std::string generate_segment_wildcard_regexp(
57255751
#endif
57265752
/* end file include/ada/url_pattern_helpers.h */
57275753

5754+
#include <string>
57285755
#include <string_view>
57295756
#include <variant>
57305757

@@ -6257,6 +6284,7 @@ ada_warn_unused std::string to_string(ada::state s);
62576284

62586285

62596286
#include <string>
6287+
#include <string_view>
62606288
#include <optional>
62616289

62626290
/**
@@ -6870,6 +6898,7 @@ namespace ada {
68706898
#ifndef ADA_URL_AGGREGATOR_H
68716899
#define ADA_URL_AGGREGATOR_H
68726900

6901+
#include <ostream>
68736902
#include <string>
68746903
#include <string_view>
68756904
#include <variant>
@@ -7255,6 +7284,7 @@ ada_really_inline size_t percent_encode_index(const std::string_view input,
72557284
/* end file include/ada/unicode-inl.h */
72567285

72577286
#include <charconv>
7287+
#include <ostream>
72587288
#include <string_view>
72597289

72607290
namespace ada {
@@ -8406,6 +8436,8 @@ using url_search_params_entries_iter =
84068436
url_search_params_iter_type::ENTRIES>;
84078437

84088438
/**
8439+
* We require all strings to be valid UTF-8. It is the user's responsibility to
8440+
* ensure that the provided strings are valid UTF-8.
84098441
* @see https://url.spec.whatwg.org/#interface-urlsearchparams
84108442
*/
84118443
struct url_search_params {
@@ -8428,6 +8460,7 @@ struct url_search_params {
84288460
[[nodiscard]] inline size_t size() const noexcept;
84298461

84308462
/**
8463+
* Both key and value must be valid UTF-8.
84318464
* @see https://url.spec.whatwg.org/#dom-urlsearchparams-append
84328465
*/
84338466
inline void append(std::string_view key, std::string_view value);
@@ -8455,6 +8488,7 @@ struct url_search_params {
84558488
inline bool has(std::string_view key, std::string_view value) noexcept;
84568489

84578490
/**
8491+
* Both key and value must be valid UTF-8.
84588492
* @see https://url.spec.whatwg.org/#dom-urlsearchparams-set
84598493
*/
84608494
inline void set(std::string_view key, std::string_view value);
@@ -8518,6 +8552,7 @@ struct url_search_params {
85188552
std::vector<key_value_pair> params{};
85198553

85208554
/**
8555+
* The init parameter must be valid UTF-8.
85218556
* @see https://url.spec.whatwg.org/#concept-urlencoded-parser
85228557
*/
85238558
void initialize(std::string_view init);
@@ -8724,10 +8759,80 @@ inline void url_search_params::remove(const std::string_view key,
87248759
}
87258760

87268761
inline void url_search_params::sort() {
8727-
std::ranges::stable_sort(
8728-
params, [](const key_value_pair &lhs, const key_value_pair &rhs) {
8729-
return lhs.first < rhs.first;
8730-
});
8762+
// We rely on the fact that the content is valid UTF-8.
8763+
std::ranges::stable_sort(params, [](const key_value_pair &lhs,
8764+
const key_value_pair &rhs) {
8765+
size_t i = 0, j = 0;
8766+
uint32_t low_surrogate1 = 0, low_surrogate2 = 0;
8767+
while ((i < lhs.first.size() || low_surrogate1 != 0) &&
8768+
(j < rhs.first.size() || low_surrogate2 != 0)) {
8769+
uint32_t codePoint1 = 0, codePoint2 = 0;
8770+
8771+
if (low_surrogate1 != 0) {
8772+
codePoint1 = low_surrogate1;
8773+
low_surrogate1 = 0;
8774+
} else {
8775+
uint8_t c1 = uint8_t(lhs.first[i]);
8776+
if (c1 <= 0x7F) {
8777+
codePoint1 = c1;
8778+
i++;
8779+
} else if (c1 <= 0xDF) {
8780+
codePoint1 = ((c1 & 0x1F) << 6) | (uint8_t(lhs.first[i + 1]) & 0x3F);
8781+
i += 2;
8782+
} else if (c1 <= 0xEF) {
8783+
codePoint1 = ((c1 & 0x0F) << 12) |
8784+
((uint8_t(lhs.first[i + 1]) & 0x3F) << 6) |
8785+
(uint8_t(lhs.first[i + 2]) & 0x3F);
8786+
i += 3;
8787+
} else {
8788+
codePoint1 = ((c1 & 0x07) << 18) |
8789+
((uint8_t(lhs.first[i + 1]) & 0x3F) << 12) |
8790+
((uint8_t(lhs.first[i + 2]) & 0x3F) << 6) |
8791+
(uint8_t(lhs.first[i + 3]) & 0x3F);
8792+
i += 4;
8793+
8794+
codePoint1 -= 0x10000;
8795+
uint16_t high_surrogate = uint16_t(0xD800 + (codePoint1 >> 10));
8796+
low_surrogate1 = uint16_t(0xDC00 + (codePoint1 & 0x3FF));
8797+
codePoint1 = high_surrogate;
8798+
}
8799+
}
8800+
8801+
if (low_surrogate2 != 0) {
8802+
codePoint2 = low_surrogate2;
8803+
low_surrogate2 = 0;
8804+
} else {
8805+
uint8_t c2 = uint8_t(rhs.first[j]);
8806+
if (c2 <= 0x7F) {
8807+
codePoint2 = c2;
8808+
j++;
8809+
} else if (c2 <= 0xDF) {
8810+
codePoint2 = ((c2 & 0x1F) << 6) | (uint8_t(rhs.first[j + 1]) & 0x3F);
8811+
j += 2;
8812+
} else if (c2 <= 0xEF) {
8813+
codePoint2 = ((c2 & 0x0F) << 12) |
8814+
((uint8_t(rhs.first[j + 1]) & 0x3F) << 6) |
8815+
(uint8_t(rhs.first[j + 2]) & 0x3F);
8816+
j += 3;
8817+
} else {
8818+
codePoint2 = ((c2 & 0x07) << 18) |
8819+
((uint8_t(rhs.first[j + 1]) & 0x3F) << 12) |
8820+
((uint8_t(rhs.first[j + 2]) & 0x3F) << 6) |
8821+
(uint8_t(rhs.first[j + 3]) & 0x3F);
8822+
j += 4;
8823+
codePoint2 -= 0x10000;
8824+
uint16_t high_surrogate = uint16_t(0xD800 + (codePoint2 >> 10));
8825+
low_surrogate2 = uint16_t(0xDC00 + (codePoint2 & 0x3FF));
8826+
codePoint2 = high_surrogate;
8827+
}
8828+
}
8829+
8830+
if (codePoint1 != codePoint2) {
8831+
return (codePoint1 < codePoint2);
8832+
}
8833+
}
8834+
return (j < rhs.first.size() || low_surrogate2 != 0);
8835+
});
87318836
}
87328837

87338838
inline url_search_params_keys_iter url_search_params::get_keys() {
@@ -10330,14 +10435,14 @@ constructor_string_parser<regex_provider>::parse(std::string_view input) {
1033010435
#ifndef ADA_ADA_VERSION_H
1033110436
#define ADA_ADA_VERSION_H
1033210437

10333-
#define ADA_VERSION "3.0.1"
10438+
#define ADA_VERSION "3.1.0"
1033410439

1033510440
namespace ada {
1033610441

1033710442
enum {
1033810443
ADA_VERSION_MAJOR = 3,
10339-
ADA_VERSION_MINOR = 0,
10340-
ADA_VERSION_REVISION = 1,
10444+
ADA_VERSION_MINOR = 1,
10445+
ADA_VERSION_REVISION = 0,
1034110446
};
1034210447

1034310448
} // namespace ada

0 commit comments

Comments
 (0)