Skip to content

Commit 5404a64

Browse files
committed
add alternate label separator tests
1 parent 124629b commit 5404a64

File tree

10 files changed

+43
-1
lines changed

10 files changed

+43
-1
lines changed

#/tests/0/87.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "single dot",
3+
"data": ".",
4+
"valid": false
5+
}

#/tests/0/88.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "single ideographic full stop",
3+
"data": "",
4+
"valid": false
5+
}

#/tests/0/89.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "single fullwidth full stop",
3+
"data": "",
4+
"valid": false
5+
}

#/tests/0/90.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "single halfwidth ideographic full stop",
3+
"data": "",
4+
"valid": false
5+
}

#/tests/0/91.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "dot as label separator",
3+
"data": "a.b",
4+
"valid": true
5+
}

#/tests/0/92.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "ideographic full stop as label separator",
3+
"data": "a。b",
4+
"valid": true
5+
}

#/tests/0/93.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "fullwidth full stop as label separator",
3+
"data": "a.b",
4+
"valid": true
5+
}

#/tests/0/94.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "halfwidth ideographic full stop as label separator",
3+
"data": "a。b",
4+
"valid": true
5+
}

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ function isIdnHostname(hostname) {
142142
// validate bidi
143143
bidiClasses.push(getRange(bidi_ranges, cp));
144144
if (j === cps.length - 1 && (bidiClasses.includes('R') || bidiClasses.includes('AL'))) {
145+
// order of chars in label (RFC 5890 §2.3.3)
145146
if (bidiClasses[0] === 'R' || bidiClasses[0] === 'AL') {
146147
for (let cls of bidiClasses) if (!['R', 'AL', 'AN', 'EN', 'ET', 'ES', 'CS', 'ON', 'BN', 'NSM'].includes(cls)) throwIdnaBidiError(`'${label}' breaks rule #2: Only R, AL, AN, EN, ET, ES, CS, ON, BN, NSM allowed in label (RFC 5893 §2.2)`);
147148
if (!/(R|AL|EN|AN)(NSM)*$/.test(bidiClasses.join(''))) throwIdnaBidiError(`'${label}' breaks rule #3: label must end with R, AL, EN, or AN, followed by zero or more NSM (RFC 5893 §2.3)`);

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Each release will have its `major` and `minor` version identical with the relate
105105
6. **Mapping phase (at validation time)**:
106106

107107
- For each input label the validator:
108-
1. Splits the hostname into labels (by `.`). Empty labels are rejected.
108+
1. Splits the hostname into labels (by `.` or alternate label separators). Empty labels are rejected.
109109
2. For each label, maps codepoints according to `mappings` (`valid` and `deviation` are passed as they are, `mapped` are replaced with the corresponding codepoints, `ignored` are ignored, any other chars are triggering `IdnaUnicodeError`).
110110
3. Normalizes the resulting mapped label with NFC.
111111
4. Checks length limits (label ≤ 63, full name ≤ 253 octets after ASCII punycode conversion).
@@ -155,6 +155,7 @@ Each release will have its `major` and `minor` version identical with the relate
155155

156156
## What does _not_ do
157157

158+
- This validator does not support `context` or `locale` specific [Special Casing](https://www.unicode.org/Public/16.0.0/ucd/SpecialCasing.txt) mappings. For such needs some sort of `mapping` must be done before using this validator.
158159
- This validator does not support `UTS#46 useTransitional` backward compatibility flag.
159160
- This validator does not support `UTS#46 STD3 ASCII rules`, when required they can be enforced on separate layer.
160161
- This validator does not attempt to resolve or query DNS — it only validates label syntax/mapping/contextual/bidi rules.

0 commit comments

Comments
 (0)