| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5709133 commit d08dd80
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - /* auto-generated on 2023-04-20 18:39:35 -0400. Do not edit! */ | ||
| 1 | + /* auto-generated on 2023-04-26 16:43:37 -0400. Do not edit! */ | ||
| 2 | 2 | /* begin file src/ada.cpp */ | |
| 3 | 3 | #include "ada.h" | |
| 4 | 4 | /* begin file src/checkers.cpp */ | |
@@ -116,12 +116,13 @@ ada_really_inline constexpr bool verify_dns_length( | |||
| 116 | 116 | ||
| 117 | 117 | ADA_PUSH_DISABLE_ALL_WARNINGS | |
| 118 | 118 | /* begin file src/ada_idna.cpp */ | |
| 119 | - /* auto-generated on 2023-03-28 11:03:13 -0400. Do not edit! */ | ||
| 119 | + /* auto-generated on 2023-04-26 14:14:42 -0400. Do not edit! */ | ||
| 120 | 120 | /* begin file src/idna.cpp */ | |
| 121 | 121 | /* begin file src/unicode_transcoding.cpp */ | |
| 122 | 122 | ||
| 123 | 123 | #include <cstdint> | |
| 124 | 124 | #include <cstring> | |
| 125 | + | ||
| 125 | 126 | namespace ada::idna { | |
| 126 | 127 | ||
| 127 | 128 | size_t utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) { | |
@@ -2750,7 +2751,9 @@ uint32_t find_range_index(uint32_t key) { | |||
| 2750 | 2751 | } | |
| 2751 | 2752 | ||
| 2752 | 2753 | bool ascii_has_upper_case(char* input, size_t length) { | |
| 2753 | - auto broadcast = [](uint8_t v) -> uint64_t { return 0x101010101010101 * v; }; | ||
| 2754 | + auto broadcast = [](uint8_t v) -> uint64_t { | ||
| 2755 | + return 0x101010101010101ull * v; | ||
| 2756 | + }; | ||
| 2754 | 2757 | uint64_t broadcast_80 = broadcast(0x80); | |
| 2755 | 2758 | uint64_t broadcast_Ap = broadcast(128 - 'A'); | |
| 2756 | 2759 | uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1); | |
@@ -2772,7 +2775,9 @@ bool ascii_has_upper_case(char* input, size_t length) { | |||
| 2772 | 2775 | } | |
| 2773 | 2776 | ||
| 2774 | 2777 | void ascii_map(char* input, size_t length) { | |
| 2775 | - auto broadcast = [](uint8_t v) -> uint64_t { return 0x101010101010101 * v; }; | ||
| 2778 | + auto broadcast = [](uint8_t v) -> uint64_t { | ||
| 2779 | + return 0x101010101010101ull * v; | ||
| 2780 | + }; | ||
| 2776 | 2781 | uint64_t broadcast_80 = broadcast(0x80); | |
| 2777 | 2782 | uint64_t broadcast_Ap = broadcast(128 - 'A'); | |
| 2778 | 2783 | uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1); | |
@@ -7999,9 +8004,10 @@ const char32_t uninorms::decomposition_data[] = { | |||
| 7999 | 8004 | namespace ada::idna { | |
| 8000 | 8005 | ||
| 8001 | 8006 | void normalize(std::u32string& input) { | |
| 8002 | - // [Normalize](https://www.unicode.org/reports/tr46/#ProcessingStepNormalize). | ||
| 8003 | - // Normalize | ||
| 8004 | - // the domain_name string to Unicode Normalization Form C. | ||
| 8007 | + /** | ||
| 8008 | + * Normalize the domain_name string to Unicode Normalization Form C. | ||
| 8009 | + * @see https://www.unicode.org/reports/tr46/#ProcessingStepNormalize | ||
| 8010 | + */ | ||
| 8005 | 8011 | ufal::unilib::uninorms::nfc(input); | |
| 8006 | 8012 | } | |
| 8007 | 8013 | ||
@@ -8229,7 +8235,6 @@ bool utf32_to_punycode(std::u32string_view input, std::string &out) { | |||
| 8229 | 8235 | } // namespace ada::idna | |
| 8230 | 8236 | /* end file src/punycode.cpp */ | |
| 8231 | 8237 | /* begin file src/validity.cpp */ | |
| 8232 | - | ||
| 8233 | 8238 | #include <algorithm> | |
| 8234 | 8239 | #include <string_view> | |
| 8235 | 8240 | ||
@@ -9617,18 +9622,18 @@ constexpr static uint8_t is_forbidden_domain_code_point_table[] = { | |||
| 9617 | 9622 | ||
| 9618 | 9623 | static_assert(sizeof(is_forbidden_domain_code_point_table) == 256); | |
| 9619 | 9624 | ||
| 9620 | - inline constexpr bool is_forbidden_domain_code_point(const char c) noexcept { | ||
| 9625 | + inline bool is_forbidden_domain_code_point(const char c) noexcept { | ||
| 9621 | 9626 | return is_forbidden_domain_code_point_table[uint8_t(c)]; | |
| 9622 | 9627 | } | |
| 9623 | 9628 | ||
| 9624 | - // We return "" on error. For now. | ||
| 9625 | - std::string from_ascii_to_ascii(std::string_view ut8_string) { | ||
| 9626 | - static const std::string error = ""; | ||
| 9627 | - if (std::any_of(ut8_string.begin(), ut8_string.end(), | ||
| 9628 | - is_forbidden_domain_code_point)) { | ||
| 9629 | - return error; | ||
| 9630 | - } | ||
| 9629 | + bool contains_forbidden_domain_code_point(std::string_view view) { | ||
| 9630 | + return ( | ||
| 9631 | + std::any_of(view.begin(), view.end(), is_forbidden_domain_code_point)); | ||
| 9632 | + } | ||
| 9631 | 9633 | ||
| 9634 | + // We return "" on error. | ||
| 9635 | + static std::string from_ascii_to_ascii(std::string_view ut8_string) { | ||
| 9636 | + static const std::string error = ""; | ||
| 9632 | 9637 | // copy and map | |
| 9633 | 9638 | // we could be more efficient by avoiding the copy when unnecessary. | |
| 9634 | 9639 | std::string mapped_string = std::string(ut8_string); | |
@@ -9682,7 +9687,7 @@ std::string from_ascii_to_ascii(std::string_view ut8_string) { | |||
| 9682 | 9687 | return out; | |
| 9683 | 9688 | } | |
| 9684 | 9689 | ||
| 9685 | - // We return "" on error. For now. | ||
| 9690 | + // We return "" on error. | ||
| 9686 | 9691 | std::string to_ascii(std::string_view ut8_string) { | |
| 9687 | 9692 | if (is_ascii(ut8_string)) { | |
| 9688 | 9693 | return from_ascii_to_ascii(ut8_string); | |
@@ -9769,11 +9774,6 @@ std::string to_ascii(std::string_view ut8_string) { | |||
| 9769 | 9774 | out.push_back('.'); | |
| 9770 | 9775 | } | |
| 9771 | 9776 | } | |
| 9772 | - | ||
| 9773 | - if (std::any_of(out.begin(), out.end(), is_forbidden_domain_code_point)) { | ||
| 9774 | - return error; | ||
| 9775 | - } | ||
| 9776 | - | ||
| 9777 | 9777 | return out; | |
| 9778 | 9778 | } | |
| 9779 | 9779 | } // namespace ada::idna | |
@@ -9842,7 +9842,9 @@ ADA_POP_DISABLE_WARNINGS | |||
| 9842 | 9842 | namespace ada::unicode { | |
| 9843 | 9843 | ||
| 9844 | 9844 | constexpr bool to_lower_ascii(char* input, size_t length) noexcept { | |
| 9845 | - auto broadcast = [](uint8_t v) -> uint64_t { return 0x101010101010101 * v; }; | ||
| 9845 | + auto broadcast = [](uint8_t v) -> uint64_t { | ||
| 9846 | + return 0x101010101010101ull * v; | ||
| 9847 | + }; | ||
| 9846 | 9848 | uint64_t broadcast_80 = broadcast(0x80); | |
| 9847 | 9849 | uint64_t broadcast_Ap = broadcast(128 - 'A'); | |
| 9848 | 9850 | uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1); | |
@@ -9873,7 +9875,9 @@ ada_really_inline constexpr bool has_tabs_or_newline( | |||
| 9873 | 9875 | auto has_zero_byte = [](uint64_t v) { | |
| 9874 | 9876 | return ((v - 0x0101010101010101) & ~(v)&0x8080808080808080); | |
| 9875 | 9877 | }; | |
| 9876 | - auto broadcast = [](uint8_t v) -> uint64_t { return 0x101010101010101 * v; }; | ||
| 9878 | + auto broadcast = [](uint8_t v) -> uint64_t { | ||
| 9879 | + return 0x101010101010101ull * v; | ||
| 9880 | + }; | ||
| 9877 | 9881 | size_t i = 0; | |
| 9878 | 9882 | uint64_t mask1 = broadcast('\r'); | |
| 9879 | 9883 | uint64_t mask2 = broadcast('\n'); | |
@@ -10252,7 +10256,8 @@ bool to_ascii(std::optional<std::string>& out, const std::string_view plain, | |||
| 10252 | 10256 | } | |
| 10253 | 10257 | // input is a non-empty UTF-8 string, must be percent decoded | |
| 10254 | 10258 | std::string idna_ascii = ada::idna::to_ascii(input); | |
| 10255 | - if (idna_ascii.empty()) { | ||
| 10259 | + if (idna_ascii.empty() || contains_forbidden_domain_code_point( | ||
| 10260 | + idna_ascii.data(), idna_ascii.size())) { | ||
| 10256 | 10261 | return false; | |
| 10257 | 10262 | } | |
| 10258 | 10263 | out = std::move(idna_ascii); | |
@@ -10627,7 +10632,9 @@ ada_really_inline size_t find_next_host_delimiter_special( | |||
| 10627 | 10632 | auto index_of_first_set_byte = [](uint64_t v) { | |
| 10628 | 10633 | return ((((v - 1) & 0x101010101010101) * 0x101010101010101) >> 56) - 1; | |
| 10629 | 10634 | }; | |
| 10630 | - auto broadcast = [](uint8_t v) -> uint64_t { return 0x101010101010101 * v; }; | ||
| 10635 | + auto broadcast = [](uint8_t v) -> uint64_t { | ||
| 10636 | + return 0x101010101010101ull * v; | ||
| 10637 | + }; | ||
| 10631 | 10638 | size_t i = location; | |
| 10632 | 10639 | uint64_t mask1 = broadcast(':'); | |
| 10633 | 10640 | uint64_t mask2 = broadcast('/'); | |
@@ -10690,7 +10697,9 @@ ada_really_inline size_t find_next_host_delimiter(std::string_view view, | |||
| 10690 | 10697 | auto index_of_first_set_byte = [](uint64_t v) { | |
| 10691 | 10698 | return ((((v - 1) & 0x101010101010101) * 0x101010101010101) >> 56) - 1; | |
| 10692 | 10699 | }; | |
| 10693 | - auto broadcast = [](uint8_t v) -> uint64_t { return 0x101010101010101 * v; }; | ||
| 10700 | + auto broadcast = [](uint8_t v) -> uint64_t { | ||
| 10701 | + return 0x101010101010101ull * v; | ||
| 10702 | + }; | ||
| 10694 | 10703 | size_t i = location; | |
| 10695 | 10704 | uint64_t mask1 = broadcast(':'); | |
| 10696 | 10705 | uint64_t mask2 = broadcast('/'); | |
@@ -11016,7 +11025,9 @@ find_authority_delimiter_special(std::string_view view) noexcept { | |||
| 11016 | 11025 | auto index_of_first_set_byte = [](uint64_t v) { | |
| 11017 | 11026 | return ((((v - 1) & 0x101010101010101) * 0x101010101010101) >> 56) - 1; | |
| 11018 | 11027 | }; | |
| 11019 | - auto broadcast = [](uint8_t v) -> uint64_t { return 0x101010101010101 * v; }; | ||
| 11028 | + auto broadcast = [](uint8_t v) -> uint64_t { | ||
| 11029 | + return 0x101010101010101ull * v; | ||
| 11030 | + }; | ||
| 11020 | 11031 | size_t i = 0; | |
| 11021 | 11032 | uint64_t mask1 = broadcast('@'); | |
| 11022 | 11033 | uint64_t mask2 = broadcast('/'); | |
@@ -11064,7 +11075,9 @@ find_authority_delimiter(std::string_view view) noexcept { | |||
| 11064 | 11075 | auto index_of_first_set_byte = [](uint64_t v) { | |
| 11065 | 11076 | return ((((v - 1) & 0x101010101010101) * 0x101010101010101) >> 56) - 1; | |
| 11066 | 11077 | }; | |
| 11067 | - auto broadcast = [](uint8_t v) -> uint64_t { return 0x101010101010101 * v; }; | ||
| 11078 | + auto broadcast = [](uint8_t v) -> uint64_t { | ||
| 11079 | + return 0x101010101010101ull * v; | ||
| 11080 | + }; | ||
| 11068 | 11081 | size_t i = 0; | |
| 11069 | 11082 | uint64_t mask1 = broadcast('@'); | |
| 11070 | 11083 | uint64_t mask2 = broadcast('/'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - /* auto-generated on 2023-04-20 18:39:35 -0400. Do not edit! */ | ||
| 1 | + /* auto-generated on 2023-04-26 16:43:37 -0400. Do not edit! */ | ||
| 2 | 2 | /* begin file include/ada.h */ | |
| 3 | 3 | /** | |
| 4 | 4 | * @file ada.h | |
@@ -8,7 +8,7 @@ | |||
| 8 | 8 | #define ADA_H | |
| 9 | 9 | ||
| 10 | 10 | /* begin file include/ada/ada_idna.h */ | |
| 11 | - /* auto-generated on 2023-03-28 11:03:13 -0400. Do not edit! */ | ||
| 11 | + /* auto-generated on 2023-04-26 14:14:42 -0400. Do not edit! */ | ||
| 12 | 12 | /* begin file include/idna.h */ | |
| 13 | 13 | #ifndef ADA_IDNA_H | |
| 14 | 14 | #define ADA_IDNA_H | |
@@ -40,6 +40,7 @@ size_t utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output); | |||
| 40 | 40 | ||
| 41 | 41 | #include <string> | |
| 42 | 42 | #include <string_view> | |
| 43 | + | ||
| 43 | 44 | namespace ada::idna { | |
| 44 | 45 | ||
| 45 | 46 | // If the input is ascii, then the mapping is just -> lower case. | |
@@ -59,6 +60,7 @@ std::u32string map(std::u32string_view input); | |||
| 59 | 60 | ||
| 60 | 61 | #include <string> | |
| 61 | 62 | #include <string_view> | |
| 63 | + | ||
| 62 | 64 | namespace ada::idna { | |
| 63 | 65 | ||
| 64 | 66 | // Normalize the characters according to IDNA (Unicode Normalization Form C). | |
@@ -73,6 +75,7 @@ void normalize(std::u32string& input); | |||
| 73 | 75 | ||
| 74 | 76 | #include <string> | |
| 75 | 77 | #include <string_view> | |
| 78 | + | ||
| 76 | 79 | namespace ada::idna { | |
| 77 | 80 | ||
| 78 | 81 | bool punycode_to_utf32(std::string_view input, std::u32string& out); | |
@@ -109,23 +112,31 @@ bool is_label_valid(const std::u32string_view label); | |||
| 109 | 112 | #include <string_view> | |
| 110 | 113 | ||
| 111 | 114 | namespace ada::idna { | |
| 115 | + | ||
| 112 | 116 | // Converts a domain (e.g., www.google.com) possibly containing international | |
| 113 | 117 | // characters to an ascii domain (with punycode). It will not do percent | |
| 114 | 118 | // decoding: percent decoding should be done prior to calling this function. We | |
| 115 | 119 | // do not remove tabs and spaces, they should have been removed prior to calling | |
| 116 | 120 | // this function. We also do not trim control characters. We also assume that | |
| 117 | - // the input is not empty. We return "" on error. For now. | ||
| 121 | + // the input is not empty. We return "" on error. | ||
| 122 | + // | ||
| 123 | + // Example: "www.öbb.at" -> "www.xn--bb-eka.at" | ||
| 124 | + // | ||
| 125 | + // This function may accept or even produce invalid domains. | ||
| 118 | 126 | std::string to_ascii(std::string_view ut8_string); | |
| 119 | 127 | ||
| 128 | + // Returns true if the string contains a forbidden code point according to the | ||
| 129 | + // WHATGL URL specification: | ||
| 130 | + // https://url.spec.whatwg.org/#forbidden-domain-code-point | ||
| 131 | + bool contains_forbidden_domain_code_point(std::string_view ascii_string); | ||
| 132 | + | ||
| 120 | 133 | bool constexpr begins_with(std::u32string_view view, | |
| 121 | 134 | std::u32string_view prefix); | |
| 122 | 135 | bool constexpr begins_with(std::string_view view, std::string_view prefix); | |
| 123 | 136 | ||
| 124 | 137 | bool constexpr is_ascii(std::u32string_view view); | |
| 125 | 138 | bool constexpr is_ascii(std::string_view view); | |
| 126 | 139 | ||
| 127 | - std::string from_ascii_to_ascii(std::string_view ut8_string); | ||
| 128 | - | ||
| 129 | 140 | } // namespace ada::idna | |
| 130 | 141 | ||
| 131 | 142 | #endif // ADA_IDNA_TO_ASCII_H | |
@@ -135,8 +146,12 @@ std::string from_ascii_to_ascii(std::string_view ut8_string); | |||
| 135 | 146 | #ifndef ADA_IDNA_TO_UNICODE_H | |
| 136 | 147 | #define ADA_IDNA_TO_UNICODE_H | |
| 137 | 148 | ||
| 149 | + #include <string_view> | ||
| 150 | + | ||
| 138 | 151 | namespace ada::idna { | |
| 152 | + | ||
| 139 | 153 | std::string to_unicode(std::string_view input); | |
| 154 | + | ||
| 140 | 155 | } // namespace ada::idna | |
| 141 | 156 | ||
| 142 | 157 | #endif // ADA_IDNA_TO_UNICODE_H | |
@@ -5138,6 +5153,7 @@ struct url : url_base { | |||
| 5138 | 5153 | [[nodiscard]] inline bool has_hash() const noexcept override; | |
| 5139 | 5154 | /** @return true if the URL has a search component */ | |
| 5140 | 5155 | [[nodiscard]] inline bool has_search() const noexcept override; | |
| 5156 | + | ||
| 5141 | 5157 | private: | |
| 5142 | 5158 | friend ada::url ada::parser::parse_url<ada::url>(std::string_view, | |
| 5143 | 5159 | const ada::url *); | |
@@ -5305,8 +5321,7 @@ namespace ada { | |||
| 5305 | 5321 | [[nodiscard]] ada_really_inline bool url::has_credentials() const noexcept { | |
| 5306 | 5322 | return !username.empty() || !password.empty(); | |
| 5307 | 5323 | } | |
| 5308 | - [[nodiscard]] ada_really_inline bool url::has_port() | ||
| 5309 | - const noexcept { | ||
| 5324 | + [[nodiscard]] ada_really_inline bool url::has_port() const noexcept { | ||
| 5310 | 5325 | return port.has_value(); | |
| 5311 | 5326 | } | |
| 5312 | 5327 | [[nodiscard]] inline bool url::cannot_have_credentials_or_port() const { | |
@@ -5439,9 +5454,13 @@ inline void url::clear_pathname() { path.clear(); } | |||
| 5439 | 5454 | ||
| 5440 | 5455 | inline void url::clear_search() { query = std::nullopt; } | |
| 5441 | 5456 | ||
| 5442 | - [[nodiscard]] inline bool url::has_hash() const noexcept { return hash.has_value(); } | ||
| 5457 | + [[nodiscard]] inline bool url::has_hash() const noexcept { | ||
| 5458 | + return hash.has_value(); | ||
| 5459 | + } | ||
| 5443 | 5460 | ||
| 5444 | - [[nodiscard]] inline bool url::has_search() const noexcept { return query.has_value(); } | ||
| 5461 | + [[nodiscard]] inline bool url::has_search() const noexcept { | ||
| 5462 | + return query.has_value(); | ||
| 5463 | + } | ||
| 5445 | 5464 | ||
| 5446 | 5465 | inline void url::set_protocol_as_file() { type = ada::scheme::type::FILE; } | |
| 5447 | 5466 | ||
@@ -6456,13 +6475,13 @@ inline std::ostream &operator<<(std::ostream &out, | |||
| 6456 | 6475 | #ifndef ADA_ADA_VERSION_H | |
| 6457 | 6476 | #define ADA_ADA_VERSION_H | |
| 6458 | 6477 | ||
| 6459 | - #define ADA_VERSION "2.2.0" | ||
| 6478 | + #define ADA_VERSION "2.3.0" | ||
| 6460 | 6479 | ||
| 6461 | 6480 | namespace ada { | |
| 6462 | 6481 | ||
| 6463 | 6482 | enum { | |
| 6464 | 6483 | ADA_VERSION_MAJOR = 2, | |
| 6465 | - ADA_VERSION_MINOR = 2, | ||
| 6484 | + ADA_VERSION_MINOR = 3, | ||
| 6466 | 6485 | ADA_VERSION_REVISION = 0, | |
| 6467 | 6486 | }; | |
| 6468 | 6487 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments