mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
LibUnicode: Support IgnorePunnycode option in ToAscii algorithm
This was introduced in UTS 46 revision 31.
This commit is contained in:
parent
5dfb825c5c
commit
923ab8658e
Notes:
github-actions[bot]
2024-12-05 16:30:43 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/923ab8658e4 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2675
2 changed files with 11 additions and 0 deletions
|
@ -45,12 +45,17 @@ ErrorOr<String> to_ascii(Utf8View domain_name, ToAsciiOptions const& options)
|
|||
errors &= ~UIDNA_ERROR_LEADING_HYPHEN;
|
||||
errors &= ~UIDNA_ERROR_TRAILING_HYPHEN;
|
||||
}
|
||||
|
||||
if (options.verify_dns_length == VerifyDnsLength::No) {
|
||||
errors &= ~UIDNA_ERROR_EMPTY_LABEL;
|
||||
errors &= ~UIDNA_ERROR_LABEL_TOO_LONG;
|
||||
errors &= ~UIDNA_ERROR_DOMAIN_NAME_TOO_LONG;
|
||||
}
|
||||
|
||||
if (options.ignore_invalid_punycode == IgnoreInvalidPunycode::Yes) {
|
||||
errors &= ~UIDNA_ERROR_PUNYCODE;
|
||||
}
|
||||
|
||||
if (icu_failure(status) || errors != 0)
|
||||
return Error::from_string_literal("Unable to convert domain to ASCII");
|
||||
|
||||
|
|
|
@ -42,6 +42,11 @@ enum class VerifyDnsLength {
|
|||
Yes,
|
||||
};
|
||||
|
||||
enum class IgnoreInvalidPunycode {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
|
||||
struct ToAsciiOptions {
|
||||
CheckHyphens check_hyphens { CheckHyphens::Yes };
|
||||
CheckBidi check_bidi { CheckBidi::Yes };
|
||||
|
@ -49,6 +54,7 @@ struct ToAsciiOptions {
|
|||
UseStd3AsciiRules use_std3_ascii_rules { UseStd3AsciiRules::No };
|
||||
TransitionalProcessing transitional_processing { TransitionalProcessing::No };
|
||||
VerifyDnsLength verify_dns_length { VerifyDnsLength::Yes };
|
||||
IgnoreInvalidPunycode ignore_invalid_punycode { IgnoreInvalidPunycode::No };
|
||||
};
|
||||
|
||||
ErrorOr<String> to_ascii(Utf8View domain_name, ToAsciiOptions const& = {});
|
||||
|
|
Loading…
Reference in a new issue