DNS and hostname validation utilities. More...
Functions | |
| SOURCEMETA_CORE_DNS_EXPORT auto | sourcemeta::core::is_hostname (const std::string_view value) -> bool |
| SOURCEMETA_CORE_DNS_EXPORT auto | sourcemeta::core::is_idn_hostname (const std::string_view value) -> bool |
| SOURCEMETA_CORE_DNS_EXPORT auto | sourcemeta::core::is_idn_hostname_uts46 (const std::string_view value) -> bool |
DNS and hostname validation utilities.
This functionality is included as follows:
| SOURCEMETA_CORE_DNS_EXPORT auto sourcemeta::core::is_hostname | ( | const std::string_view | value | ) | -> bool |
Check whether the given string is a valid Internet host name per RFC 1123 Section 2.1, which relaxes the first-character rule of RFC 952 to allow either a letter or a digit. For example:
This function operates on ASCII input only and caps the total length at 255 octets. Labels matching the case-insensitive "xn--" prefix are additionally validated as RFC 5890 A-labels, so the Punycode body must decode and round-trip.
| SOURCEMETA_CORE_DNS_EXPORT auto sourcemeta::core::is_idn_hostname | ( | const std::string_view | value | ) | -> bool |
Check whether the given string is a valid internationalized host name per RFC 5891 Section 4. Each label is validated as an RFC 5890 A-label or U-label (with RFC 5892 ContextJ and ContextO contextual rules and the RFC 5891 ยง4.1.2.A NFC requirement), and the RFC 5893 Bidi rule is enforced on every label of a Bidi domain name. The total length is capped at 253 octets in A-label form. For example:
| SOURCEMETA_CORE_DNS_EXPORT auto sourcemeta::core::is_idn_hostname_uts46 | ( | const std::string_view | value | ) | -> bool |
Check whether the given string is a valid internationalized host name after UTS #46 processing. The input is first mapped and normalised to NFC under UTS #46 Nontransitional Processing, then the mapped result is validated with the same IDNA 2008 per-label rules as a strict host name. This is the lookup-side behaviour: human-typed forms such as uppercase ASCII and fullwidth characters are folded before validation rather than rejected. See https://www.unicode.org/reports/tr46/ for the algorithm. For example: