Skip to content

Commit

Permalink
remove IDNA_ prefix from enum idna_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
deokjinkim committed Nov 28, 2022
1 parent ff3020e commit 5d4cb6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/node_i18n.cc
Expand Up @@ -648,7 +648,7 @@ int32_t ToASCII(MaybeStackBuffer<char>* buf,
UIDNA_CHECK_BIDI | // CheckBidi = true
UIDNA_CHECK_CONTEXTJ | // CheckJoiners = true
UIDNA_NONTRANSITIONAL_TO_ASCII; // Nontransitional_Processing
if (mode == idna_mode::IDNA_STRICT) {
if (mode == idna_mode::STRICT) {
options |= UIDNA_USE_STD3_RULES; // UseSTD3ASCIIRules = beStrict
// VerifyDnsLength = beStrict;
// handled later
Expand Down Expand Up @@ -696,15 +696,14 @@ int32_t ToASCII(MaybeStackBuffer<char>* buf,
info.errors &= ~UIDNA_ERROR_LEADING_HYPHEN;
info.errors &= ~UIDNA_ERROR_TRAILING_HYPHEN;

if (mode != idna_mode::IDNA_STRICT) {
if (mode != idna_mode::STRICT) {
// VerifyDnsLength = beStrict
info.errors &= ~UIDNA_ERROR_EMPTY_LABEL;
info.errors &= ~UIDNA_ERROR_LABEL_TOO_LONG;
info.errors &= ~UIDNA_ERROR_DOMAIN_NAME_TOO_LONG;
}

if (U_FAILURE(status) ||
(mode != idna_mode::IDNA_LENIENT && info.errors != 0)) {
if (U_FAILURE(status) || (mode != idna_mode::LENIENT && info.errors != 0)) {
len = -1;
buf->SetLength(0);
} else {
Expand Down Expand Up @@ -742,7 +741,7 @@ static void ToASCII(const FunctionCallbackInfo<Value>& args) {
Utf8Value val(env->isolate(), args[0]);
// optional arg
bool lenient = args[1]->BooleanValue(env->isolate());
idna_mode mode = lenient ? idna_mode::IDNA_LENIENT : idna_mode::IDNA_DEFAULT;
idna_mode mode = lenient ? idna_mode::LENIENT : idna_mode::DEFAULT;

MaybeStackBuffer<char> buf;
int32_t len = ToASCII(&buf, *val, val.length(), mode);
Expand Down
8 changes: 4 additions & 4 deletions src/node_i18n.h
Expand Up @@ -44,21 +44,21 @@ void SetDefaultTimeZone(const char* tzid);

enum class idna_mode {
// Default mode for maximum compatibility.
IDNA_DEFAULT,
DEFAULT,
// Ignore all errors in IDNA conversion, if possible.
IDNA_LENIENT,
LENIENT,
// Enforce STD3 rules (UseSTD3ASCIIRules) and DNS length restrictions
// (VerifyDnsLength). Corresponds to `beStrict` flag in the "domain to ASCII"
// algorithm.
IDNA_STRICT
STRICT
};

// Implements the WHATWG URL Standard "domain to ASCII" algorithm.
// https://url.spec.whatwg.org/#concept-domain-to-ascii
int32_t ToASCII(MaybeStackBuffer<char>* buf,
const char* input,
size_t length,
idna_mode mode = idna_mode::IDNA_DEFAULT);
idna_mode mode = idna_mode::DEFAULT);

// Implements the WHATWG URL Standard "domain to Unicode" algorithm.
// https://url.spec.whatwg.org/#concept-domain-to-unicode
Expand Down

0 comments on commit 5d4cb6f

Please sign in to comment.