html-minifier-next 6.1.3 → 6.1.5

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.
@@ -139,10 +139,10 @@ const singleAttrValues = [
139
139
  /([^ \t\n\f\r"'`=<>]+)/.source
140
140
  ];
141
141
  // Lenient unquoted value pattern for `continueOnParseError`:
142
- // allows `=` and `` ` `` per spec error-recovery rules
143
- // (both are parse errors in unquoted-attribute-value state but appended to the value)
142
+ // allows `<`, `=`, and ``` per HTML error-recovery rules
143
+ // (all are parse errors in unquoted-attribute-value state but appended to the value)
144
144
  // `"` and `'` remain excluded—permitting them requires broader test coverage
145
- const singleAttrValueLenientUnquoted = /([^ \t\n\f\r"'<>]+)/.source;
145
+ const singleAttrValueLenientUnquoted = /([^ \t\n\f\r"'>]+)/.source;
146
146
  // https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
147
147
  const qnameCapture = (function () {
148
148
  // https://www.npmjs.com/package/ncname
@@ -611,10 +611,23 @@ class HTMLParser {
611
611
  continue;
612
612
  }
613
613
  }
614
- // Note: Unquoted attribute values are intentionally not handled here.
614
+ // Note: Unquoted attribute values are intentionally not handled here
615
615
  // Per HTML spec, unquoted values cannot contain spaces or special chars,
616
- // making a 20 KB+ unquoted value practically impossible. If encountered,
617
- // it’s malformed HTML and using the truncated regex match is acceptable.
616
+ // making a 20 KB+ unquoted value practically impossible; if encountered,
617
+ // it’s malformed HTML and using the truncated regex match is acceptable
618
+ }
619
+ } else {
620
+ // If attr has no value assign but `=` follows in `fullHtml`,
621
+ // the value would be cut off—reset to trigger manual extraction below
622
+ const numCustomParts = handler.customAttrSurround
623
+ ? handler.customAttrSurround.length * NCP
624
+ : 0;
625
+ const baseIndex = 1 + numCustomParts;
626
+ if (attr[baseIndex + 1] === undefined) {
627
+ const posAfterName = currentPos + attrEnd;
628
+ if (/^\s*=/.test(fullHtml.slice(posAfterName, posAfterName + 50))) {
629
+ attr = null;
630
+ }
618
631
  }
619
632
  }
620
633
  }
@@ -1 +1 @@
1
- {"version":3,"file":"htmlparser.d.ts","sourceRoot":"","sources":["../../src/htmlparser.js"],"names":[],"mappings":"AAqDA,4BAAkE;AA0GlE;IACE,qCAGC;IAFC,UAAgB;IAChB,aAAsB;IAGxB,uBAmmBC;CACF"}
1
+ {"version":3,"file":"htmlparser.d.ts","sourceRoot":"","sources":["../../src/htmlparser.js"],"names":[],"mappings":"AAqDA,4BAAkE;AA0GlE;IACE,qCAGC;IAFC,UAAgB;IAChB,aAAsB;IAGxB,uBAgnBC;CACF"}
package/package.json CHANGED
@@ -96,5 +96,5 @@
96
96
  },
97
97
  "type": "module",
98
98
  "types": "./dist/types/htmlminifier.d.ts",
99
- "version": "6.1.3"
99
+ "version": "6.1.5"
100
100
  }
package/src/htmlparser.js CHANGED
@@ -36,10 +36,10 @@ const singleAttrValues = [
36
36
  /([^ \t\n\f\r"'`=<>]+)/.source
37
37
  ];
38
38
  // Lenient unquoted value pattern for `continueOnParseError`:
39
- // allows `=` and `` ` `` per spec error-recovery rules
40
- // (both are parse errors in unquoted-attribute-value state but appended to the value)
39
+ // allows `<`, `=`, and ``` per HTML error-recovery rules
40
+ // (all are parse errors in unquoted-attribute-value state but appended to the value)
41
41
  // `"` and `'` remain excluded—permitting them requires broader test coverage
42
- const singleAttrValueLenientUnquoted = /([^ \t\n\f\r"'<>]+)/.source;
42
+ const singleAttrValueLenientUnquoted = /([^ \t\n\f\r"'>]+)/.source;
43
43
  // https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
44
44
  const qnameCapture = (function () {
45
45
  // https://www.npmjs.com/package/ncname
@@ -510,10 +510,23 @@ export class HTMLParser {
510
510
  continue;
511
511
  }
512
512
  }
513
- // Note: Unquoted attribute values are intentionally not handled here.
513
+ // Note: Unquoted attribute values are intentionally not handled here
514
514
  // Per HTML spec, unquoted values cannot contain spaces or special chars,
515
- // making a 20 KB+ unquoted value practically impossible. If encountered,
516
- // it’s malformed HTML and using the truncated regex match is acceptable.
515
+ // making a 20 KB+ unquoted value practically impossible; if encountered,
516
+ // it’s malformed HTML and using the truncated regex match is acceptable
517
+ }
518
+ } else {
519
+ // If attr has no value assign but `=` follows in `fullHtml`,
520
+ // the value would be cut off—reset to trigger manual extraction below
521
+ const numCustomParts = handler.customAttrSurround
522
+ ? handler.customAttrSurround.length * NCP
523
+ : 0;
524
+ const baseIndex = 1 + numCustomParts;
525
+ if (attr[baseIndex + 1] === undefined) {
526
+ const posAfterName = currentPos + attrEnd;
527
+ if (/^\s*=/.test(fullHtml.slice(posAfterName, posAfterName + 50))) {
528
+ attr = null;
529
+ }
517
530
  }
518
531
  }
519
532
  }