Skip to content

Commit 070e141

Browse files
committed
Fix A-label bug
1 parent 3553dae commit 070e141

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

#/tests/0/95.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"description": "MIDDLE DOT with surrounding 'l's as A-Label",
3+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.3",
4+
"data": "xn--ll-0ea",
5+
"valid": true
6+
}

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function isIdnHostname(hostname) {
8080
} catch (e) {
8181
throwPunycodeError(`Invalid ASCII Compatible Encoding (ACE) of label '${rawLabel}' (RFC 5891 §4.4 → RFC 3492).`);
8282
}
83-
if (/[\p{ASCII}]/u.test(label)) throwIdnaSyntaxError(`decoded A-label '${rawLabel}' result U-label '${label}' cannot be empty or all-ASCII character(s) (RFC 5890 §2.3.2.1).`);
83+
if (!/[^\p{ASCII}]/u.test(label)) throwIdnaSyntaxError(`decoded A-label '${rawLabel}' result U-label '${label}' cannot be empty or all-ASCII character(s) (RFC 5890 §2.3.2.1).`);
8484
if (punycode.encode(label) !== aceBody) throwPunycodeError(`Re-encode mismatch for ASCII Compatible Encoding (ACE) label '${rawLabel}' (RFC 5891 §4.4 → RFC 3492).`);
8585
}
8686
// mapping phase (here because decoded A-label may contain disallowed chars)

0 commit comments

Comments
 (0)