typebox 1.2.17 → 1.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/format/_idna.mjs +21 -2
- package/package.json +1 -1
package/build/format/_idna.mjs
CHANGED
|
@@ -192,10 +192,29 @@ function IsPuny(value) {
|
|
|
192
192
|
}
|
|
193
193
|
function IsPunyLabel(value) {
|
|
194
194
|
try {
|
|
195
|
-
|
|
195
|
+
const payload = value.slice(4).toLowerCase();
|
|
196
|
+
// 1. Structural Validation (RFC 3492 syntax)
|
|
197
|
+
//
|
|
198
|
+
// If the payload contains a hyphen, it MUST be a delimiter separating basic
|
|
199
|
+
// ASCII characters from the variable-length integers. A payload consisting
|
|
200
|
+
// of ONLY a hyphen or starting with multiple hyphens without basic ASCII
|
|
201
|
+
// characters (like "-9uc") is fundamentally malformed.
|
|
202
|
+
//
|
|
203
|
+
const lastHyphen = payload.lastIndexOf('-');
|
|
204
|
+
if (lastHyphen === 0) {
|
|
205
|
+
// Catches "-9uc" right here because the delimiter is at index 0, meaning 0
|
|
206
|
+
// basic ASCII characters preceded it, which is non-canonical.
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
// 2. Decode the payload
|
|
210
|
+
const decoded = Puny.Decode(payload);
|
|
211
|
+
if (!decoded)
|
|
212
|
+
return false;
|
|
213
|
+
// 3. Validate the output rules against RFC 5892
|
|
214
|
+
return IsUnicodeLabel(decoded);
|
|
196
215
|
}
|
|
197
216
|
catch {
|
|
198
|
-
return false;
|
|
217
|
+
return false;
|
|
199
218
|
}
|
|
200
219
|
}
|
|
201
220
|
// ------------------------------------------------------------------
|