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.
@@ -192,10 +192,29 @@ function IsPuny(value) {
192
192
  }
193
193
  function IsPunyLabel(value) {
194
194
  try {
195
- return IsUnicodeLabel(Puny.Decode(value.slice(4)));
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; // invalid punycode encoding
217
+ return false;
199
218
  }
200
219
  }
201
220
  // ------------------------------------------------------------------
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.2.17",
4
+ "version": "1.2.18",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"