html-minifier-next 8.3.0 → 8.3.1
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/dist/types/htmlminifier.d.ts.map +1 -1
- package/dist/types/htmlparser.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/htmlminifier.js +26 -4
- package/src/htmlparser.js +183 -136
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAqE/D,YAAkB,aAAa,GAI/B;IAAe,IAAI,EAAZ,MAAM,CACb;IAAgB,KAAK,AAArB,CACA,EADO,MAAM,CACb;IAAgB,KAAK,AAArB,CACA,EADO,MAAM,CACb;IAAgB,YAAY,AAA5B,CACA,EADO,MAAM,CACb;IAAgB,UAAU,AAA1B,CACA,EADO,MAAM,CACb;IAAgB,WAAW,AAA3B,CAA4B,EAArB,MAAM,CAAe;CAAA,CAAA;AAI5B,YAAkB,eAAe,GAIjC;;;;;;;IAA2G,qBAAqB,AAAhI,CAMA,EANO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,qBAAqB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,KAAK,OAAO,CAMxG;;;;;;;IAA0H,iBAAiB,AAA3I,CAMA,EANO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,EAAE,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,KAAK,OAAO,CAMvH;;;;;;;;;;IAAgB,QAAQ,AAAxB,CASA,EATO,MAAM,CASb;;;;;;;;;;IAAgB,OAAO,AAAvB,CASA,EATO,MAAM,CASb;;;;;;;;;;IAAgB,QAAQ,AAAxB,CASA,EATO,MAAM,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AZ,MAAM,CACb;;;;IAAe,IAAI,EAAZ,MAAM,CACb;;;;IAAe,IAAI,EAAZ,MAAM,CACb;;;;IAAe,KAAK,EAAb,MAAM,CACf;CAAA,CAAA;AA29CD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,IAFhB;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,UAAU,CAAA;CAAE,CAQhE;AA2FD;;;;GAIG;AACH,eAAO,MAAM,MAAM,UAJR,MAAM,YACN,eAAe,KACb,OAAO,CAAC,MAAM,CAsE1B,CAAC;AAIF,OAAO,EACL,OAAO,EACP,SAAS,EACT,cAAc,EACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlparser.d.ts","sourceRoot":"","sources":["../../src/htmlparser.js"],"names":[],"mappings":"AAeG,YAYG,iBAAiB,GAZV;IACR,KAAK,CAAC,WAAW;IACjB,GAAG,CAAC,WAAW;IACf,KAAK,CAAC,WAAW;IACjB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,WAAW;IACnB,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3C,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,kBAAkB,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,CAAC;IAC5C,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;CACxC,CAAmB;AA0CvB,eAAO,MAAM,MAAM,QAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"htmlparser.d.ts","sourceRoot":"","sources":["../../src/htmlparser.js"],"names":[],"mappings":"AAeG,YAYG,iBAAiB,GAZV;IACR,KAAK,CAAC,WAAW;IACjB,GAAG,CAAC,WAAW;IACf,KAAK,CAAC,WAAW;IACjB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,WAAW;IACnB,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3C,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,kBAAkB,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,CAAC;IAC5C,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;CACxC,CAAmB;AA0CvB,eAAO,MAAM,MAAM,QAA8C,CAAC;AAoLlE,qBAAa,UAAU;IAMd,IAAI;IACJ,OAAO;IANd;;;OAGG;IACH,YAAY,IAAI,EAHL,MAGK,EAAE,OAAO,EAFd,iBAEc,EAGxB;IAEK,KAAK,kBAwyBV;CACF"}
|
package/package.json
CHANGED
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
"commander": "^15.0.0",
|
|
10
10
|
"entities": "^8.0.0",
|
|
11
11
|
"lightningcss": "^1.33.0",
|
|
12
|
-
"svgo": "^4.0
|
|
13
|
-
"terser": "^5.
|
|
12
|
+
"svgo": "^4.1.0",
|
|
13
|
+
"terser": "^5.51.2"
|
|
14
14
|
},
|
|
15
15
|
"description": "Highly effective, super-configurable, well-tested web page minifier (enhanced successor to HTML Minifier)",
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@commitlint/cli": "^21.2.2",
|
|
18
18
|
"@eslint/js": "^10.0.1",
|
|
19
19
|
"@swc/core": "^1.16.1",
|
|
20
|
-
"@types/node": "^26.
|
|
20
|
+
"@types/node": "^26.4.0",
|
|
21
21
|
"eslint": "^10.9.1",
|
|
22
22
|
"globals": "^17.11.0",
|
|
23
23
|
"typescript": "^7.0.2",
|
|
24
|
-
"vite": "^8.2.
|
|
24
|
+
"vite": "^8.2.2"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
27
|
"node": ">=22.13"
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
},
|
|
96
96
|
"type": "module",
|
|
97
97
|
"types": "dist/types/htmlminifier.d.ts",
|
|
98
|
-
"version": "8.3.
|
|
98
|
+
"version": "8.3.1"
|
|
99
99
|
}
|
package/src/htmlminifier.js
CHANGED
|
@@ -956,6 +956,27 @@ async function createSortFns(value, options, uidIgnore, uidAttr, ignoredMarkupCh
|
|
|
956
956
|
}
|
|
957
957
|
}
|
|
958
958
|
|
|
959
|
+
// Match `/^<\/([\w:-]+)>$/` by hand—the regex engine’s per-call setup costs more
|
|
960
|
+
// than the scan on these short buffer entries
|
|
961
|
+
/**
|
|
962
|
+
* @param {string} str
|
|
963
|
+
* @returns {string | null} The tag name, or `null` where the string is not a plain end tag
|
|
964
|
+
*/
|
|
965
|
+
function matchPlainEndTag(str) {
|
|
966
|
+
const end = str.length;
|
|
967
|
+
if (end < 4 || str.charCodeAt(0) !== 60 /* < */ || str.charCodeAt(1) !== 47 /* / */ || str.charCodeAt(end - 1) !== 62 /* > */) {
|
|
968
|
+
return null;
|
|
969
|
+
}
|
|
970
|
+
for (let i = 2; i < end - 1; i++) {
|
|
971
|
+
const code = str.charCodeAt(i);
|
|
972
|
+
// `[\w:-]`: Letters, digits, `_`, `:`, `-`
|
|
973
|
+
if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 90) || (code >= 97 && code <= 122) || code === 95 || code === 58 || code === 45)) {
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
return str.slice(2, end - 1);
|
|
978
|
+
}
|
|
979
|
+
|
|
959
980
|
/**
|
|
960
981
|
* @param {string} value - HTML content to minify
|
|
961
982
|
* @param {ProcessedOptions} options - Normalized minification options
|
|
@@ -1198,10 +1219,11 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1198
1219
|
function trimTrailingWhitespace(/** @type {number} */ index, /** @type {string} */ nextTag) {
|
|
1199
1220
|
for (let prevTag = ''; index >= 0 && canTrimWhitespace(prevTag, emptyAttrs); index--) {
|
|
1200
1221
|
const str = buffer[index] ?? '';
|
|
1201
|
-
const
|
|
1202
|
-
if (
|
|
1203
|
-
prevTag =
|
|
1204
|
-
} else if (
|
|
1222
|
+
const endTagName = matchPlainEndTag(str);
|
|
1223
|
+
if (endTagName !== null) {
|
|
1224
|
+
prevTag = endTagName;
|
|
1225
|
+
} else if (str.charCodeAt(str.length - 1) === 62 /* > */ ||
|
|
1226
|
+
(buffer[index] = collapseWhitespaceSmart(str, '', nextTag, emptyAttrs, emptyAttrs, options, inlineElements, inlineTextSet))) {
|
|
1205
1227
|
break;
|
|
1206
1228
|
}
|
|
1207
1229
|
}
|
package/src/htmlparser.js
CHANGED
|
@@ -103,6 +103,31 @@ const nonPhrasing = new Set(['address', 'article', 'aside', 'base', 'blockquote'
|
|
|
103
103
|
const endsTagName = (/** @type {string} */ character) =>
|
|
104
104
|
character === '' || character === '/' || character === '>' || /\s/.test(character);
|
|
105
105
|
|
|
106
|
+
// Fast path for tag names
|
|
107
|
+
/**
|
|
108
|
+
* @param {string} html
|
|
109
|
+
* @param {number} start - Position of the first name character (after `<` or `</`)
|
|
110
|
+
* @returns {number} Name length from `start`, or -1 to fall back to the qname regex
|
|
111
|
+
*/
|
|
112
|
+
function scanAsciiTagName(html, start) {
|
|
113
|
+
const first = html.charCodeAt(start);
|
|
114
|
+
// First char: Letter or `_` (as for ncname)
|
|
115
|
+
if (!((first >= 65 && first <= 90) || (first >= 97 && first <= 122) || first === 95)) {
|
|
116
|
+
return -1;
|
|
117
|
+
}
|
|
118
|
+
let i = start + 1;
|
|
119
|
+
for (;;) {
|
|
120
|
+
const code = html.charCodeAt(i);
|
|
121
|
+
if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122) || (code >= 48 && code <= 57) || code === 95 || code === 45 || code === 46) {
|
|
122
|
+
i++;
|
|
123
|
+
} else if (code === 58 || code >= 128) { // `:` or non-ASCII
|
|
124
|
+
return -1;
|
|
125
|
+
} else {
|
|
126
|
+
return i - start;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
106
131
|
// The characters `\s` matches, by code: Tab through carriage return, space, and the
|
|
107
132
|
// Unicode whitespace and line terminators
|
|
108
133
|
const isWhitespaceCode = (/** @type {number} */ code) =>
|
|
@@ -374,8 +399,7 @@ export class HTMLParser {
|
|
|
374
399
|
cachedNextStartTag = null;
|
|
375
400
|
cachedNextEndTag = null;
|
|
376
401
|
advance(startTagMatch.advance);
|
|
377
|
-
await handleStartTag(startTagMatch);
|
|
378
|
-
prevTag = startTagMatch.tagName.toLowerCase();
|
|
402
|
+
prevTag = await handleStartTag(startTagMatch);
|
|
379
403
|
continue;
|
|
380
404
|
}
|
|
381
405
|
if (cachedNextEndTag && cachedNextEndTag.pos === pos) {
|
|
@@ -383,8 +407,7 @@ export class HTMLParser {
|
|
|
383
407
|
cachedNextStartTag = null;
|
|
384
408
|
cachedNextEndTag = null;
|
|
385
409
|
advance(endTagMatch.text.length);
|
|
386
|
-
await parseEndTag(endTagMatch.text, endTagMatch.name);
|
|
387
|
-
prevTag = '/' + endTagMatch.name.toLowerCase();
|
|
410
|
+
prevTag = '/' + await parseEndTag(endTagMatch.text, endTagMatch.name);
|
|
388
411
|
prevAttrs = [];
|
|
389
412
|
continue;
|
|
390
413
|
}
|
|
@@ -452,8 +475,7 @@ export class HTMLParser {
|
|
|
452
475
|
const endTagMatch = matchEndTag(pos);
|
|
453
476
|
if (endTagMatch) {
|
|
454
477
|
advance(endTagMatch.text.length);
|
|
455
|
-
await parseEndTag(endTagMatch.text, endTagMatch.name);
|
|
456
|
-
prevTag = '/' + endTagMatch.name.toLowerCase();
|
|
478
|
+
prevTag = '/' + await parseEndTag(endTagMatch.text, endTagMatch.name);
|
|
457
479
|
prevAttrs = [];
|
|
458
480
|
continue;
|
|
459
481
|
}
|
|
@@ -463,8 +485,7 @@ export class HTMLParser {
|
|
|
463
485
|
const startTagMatch = parseStartTag(pos);
|
|
464
486
|
if (startTagMatch) {
|
|
465
487
|
advance(startTagMatch.advance);
|
|
466
|
-
await handleStartTag(startTagMatch);
|
|
467
|
-
prevTag = startTagMatch.tagName.toLowerCase();
|
|
488
|
+
prevTag = await handleStartTag(startTagMatch);
|
|
468
489
|
continue;
|
|
469
490
|
}
|
|
470
491
|
}
|
|
@@ -614,17 +635,29 @@ export class HTMLParser {
|
|
|
614
635
|
* where none is complete
|
|
615
636
|
*/
|
|
616
637
|
function matchEndTag(startPos) {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
638
|
+
let name;
|
|
639
|
+
let nameEnd;
|
|
640
|
+
const scanned = scanAsciiTagName(fullHtml, startPos + 2);
|
|
641
|
+
if (scanned !== -1) {
|
|
642
|
+
nameEnd = startPos + 2 + scanned;
|
|
643
|
+
name = fullHtml.slice(startPos + 2, nameEnd);
|
|
644
|
+
} else {
|
|
645
|
+
endTagOpenY.lastIndex = startPos;
|
|
646
|
+
const open = endTagOpenY.exec(fullHtml);
|
|
647
|
+
if (!open) {
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
nameEnd = startPos + open[0].length;
|
|
651
|
+
name = open[1] ?? '';
|
|
621
652
|
}
|
|
622
|
-
const close = findEndTagClose(fullHtml,
|
|
623
|
-
return close === -1 ? null : { text: fullHtml.slice(startPos, close + 1), name
|
|
653
|
+
const close = findEndTagClose(fullHtml, nameEnd);
|
|
654
|
+
return close === -1 ? null : { text: fullHtml.slice(startPos, close + 1), name };
|
|
624
655
|
}
|
|
625
656
|
|
|
626
657
|
// Where a tag ends: After optional whitespace, at `>` or `/>`. Scanned by hand in a
|
|
627
|
-
// single pass, where a regex did the same with one execution per attribute.
|
|
658
|
+
// single pass, where a regex did the same with one execution per attribute. The
|
|
659
|
+
// result packs length and slash into one number (`length << 1 | hasSlash`, 0 for no
|
|
660
|
+
// match) so the per-attribute loop allocates nothing.
|
|
628
661
|
function matchTagClose(/** @type {number} */ currentPos) {
|
|
629
662
|
let scan = currentPos;
|
|
630
663
|
let code = fullHtml.charCodeAt(scan);
|
|
@@ -632,132 +665,89 @@ export class HTMLParser {
|
|
|
632
665
|
code = fullHtml.charCodeAt(++scan);
|
|
633
666
|
}
|
|
634
667
|
if (code === 62) { // `>`
|
|
635
|
-
return
|
|
668
|
+
return (scan - currentPos + 1) << 1;
|
|
636
669
|
}
|
|
637
670
|
if (code === 47 && fullHtml.charCodeAt(scan + 1) === 62) { // `/>`
|
|
638
|
-
return
|
|
671
|
+
return ((scan - currentPos + 2) << 1) | 1;
|
|
639
672
|
}
|
|
640
|
-
return
|
|
673
|
+
return 0;
|
|
641
674
|
}
|
|
642
675
|
|
|
643
676
|
function parseStartTag(/** @type {number} */ startPos) {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
677
|
+
let tagName;
|
|
678
|
+
let consumed;
|
|
679
|
+
const scanned = scanAsciiTagName(fullHtml, startPos + 1);
|
|
680
|
+
if (scanned !== -1) {
|
|
681
|
+
tagName = fullHtml.slice(startPos + 1, startPos + 1 + scanned);
|
|
682
|
+
consumed = 1 + scanned;
|
|
683
|
+
} else {
|
|
684
|
+
startTagOpenY.lastIndex = startPos;
|
|
685
|
+
const start = startTagOpenY.exec(fullHtml);
|
|
686
|
+
if (!start) {
|
|
687
|
+
return undefined;
|
|
688
|
+
}
|
|
689
|
+
tagName = start[1] ?? '';
|
|
690
|
+
consumed = start[0].length;
|
|
691
|
+
}
|
|
692
|
+
/** @type {{tagName: string, attrs: Array<Array<string|undefined>>, advance: number, unarySlash?: string}} */
|
|
693
|
+
const match = {
|
|
694
|
+
tagName,
|
|
695
|
+
attrs: [],
|
|
696
|
+
advance: 0
|
|
697
|
+
};
|
|
698
|
+
let currentPos = startPos + consumed;
|
|
699
|
+
let close, attr;
|
|
700
|
+
|
|
701
|
+
// Safety limit: Max length of input to check for attributes
|
|
702
|
+
// Protects against catastrophic backtracking on massive attribute values
|
|
703
|
+
const MAX_ATTR_PARSE_LENGTH = 20000; // 20 KB should be enough for any reasonable tag
|
|
704
|
+
|
|
705
|
+
while (true) {
|
|
706
|
+
// Check for closing tag first (manual scan, regex only for the unusual)
|
|
707
|
+
close = matchTagClose(currentPos);
|
|
708
|
+
if (close) {
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
671
711
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
attr = attributeY.exec(fullHtml);
|
|
676
|
-
} else {
|
|
677
|
-
const extractEndPos = currentPos + MAX_ATTR_PARSE_LENGTH;
|
|
678
|
-
|
|
679
|
-
// Create a temporary substring only for attribute parsing (limited for safety)
|
|
680
|
-
const searchStr = fullHtml.substring(currentPos, extractEndPos);
|
|
681
|
-
attr = searchStr.match(attribute);
|
|
682
|
-
|
|
683
|
-
// If input was limited and there’s a match, check if the value might be truncated
|
|
684
|
-
if (attr) {
|
|
685
|
-
// Check if the attribute value extends beyond our search window
|
|
686
|
-
const attrEnd = attr[0].length;
|
|
687
|
-
// If the match ends near the limit, the value might be truncated
|
|
688
|
-
if (attrEnd > MAX_ATTR_PARSE_LENGTH - 100) {
|
|
689
|
-
// Manually extract this attribute to handle potentially huge value
|
|
690
|
-
const manualMatch = searchStr.match(/^\s*([^\s"'<>/=]+)\s*=\s*/);
|
|
691
|
-
if (manualMatch) {
|
|
692
|
-
const quoteChar = searchStr[manualMatch[0].length];
|
|
693
|
-
if (quoteChar === '"' || quoteChar === "'") {
|
|
694
|
-
const closeQuote = searchStr.indexOf(quoteChar, manualMatch[0].length + 1);
|
|
695
|
-
if (closeQuote !== -1) {
|
|
696
|
-
const fullAttrLen = closeQuote + 1;
|
|
697
|
-
const numCustomParts = handler.customAttrSurround
|
|
698
|
-
? handler.customAttrSurround.length * NCP
|
|
699
|
-
: 0;
|
|
700
|
-
const baseIndex = 1 + numCustomParts;
|
|
701
|
-
|
|
702
|
-
attr = [];
|
|
703
|
-
attr[0] = searchStr.substring(0, fullAttrLen);
|
|
704
|
-
attr[baseIndex] = manualMatch[1]; // Attribute name
|
|
705
|
-
attr[baseIndex + 1] = '='; // `customAssign` (falls back to "=" for huge attributes)
|
|
706
|
-
const value = searchStr.substring(manualMatch[0].length + 1, closeQuote);
|
|
707
|
-
// Place value at correct index based on quote type
|
|
708
|
-
if (quoteChar === '"') {
|
|
709
|
-
attr[baseIndex + 2] = value; // Double-quoted value
|
|
710
|
-
} else {
|
|
711
|
-
attr[baseIndex + 3] = value; // Single-quoted value
|
|
712
|
-
}
|
|
713
|
-
currentPos += fullAttrLen;
|
|
714
|
-
consumed += fullAttrLen;
|
|
715
|
-
match.attrs.push(attr);
|
|
716
|
-
continue;
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
// Note: Unquoted attribute values are intentionally not handled here
|
|
720
|
-
// Per HTML spec, unquoted values cannot contain spaces or special chars,
|
|
721
|
-
// making a 20 KB+ unquoted value practically impossible; if encountered,
|
|
722
|
-
// it’s malformed HTML and using the truncated regex match is acceptable
|
|
723
|
-
}
|
|
724
|
-
} else {
|
|
725
|
-
// If attr has no value assign but `=` follows in `fullHtml`,
|
|
726
|
-
// the value would be cut off—reset to trigger manual extraction below
|
|
727
|
-
const numCustomParts = handler.customAttrSurround
|
|
728
|
-
? handler.customAttrSurround.length * NCP
|
|
729
|
-
: 0;
|
|
730
|
-
const baseIndex = 1 + numCustomParts;
|
|
731
|
-
if (attr[baseIndex + 1] === undefined) {
|
|
732
|
-
const posAfterName = currentPos + attrEnd;
|
|
733
|
-
if (/^\s*=/.test(fullHtml.slice(posAfterName, posAfterName + 50))) {
|
|
734
|
-
attr = null;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
}
|
|
712
|
+
// Limit the input length to pass to the regex to prevent catastrophic backtracking
|
|
713
|
+
const remainingLen = fullLength - currentPos;
|
|
714
|
+
const isLimited = remainingLen > MAX_ATTR_PARSE_LENGTH;
|
|
739
715
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
716
|
+
if (!isLimited) {
|
|
717
|
+
// Common case: Use sticky regex directly on full string (no slicing)
|
|
718
|
+
attributeY.lastIndex = currentPos;
|
|
719
|
+
attr = attributeY.exec(fullHtml);
|
|
720
|
+
} else {
|
|
721
|
+
const extractEndPos = currentPos + MAX_ATTR_PARSE_LENGTH;
|
|
722
|
+
|
|
723
|
+
// Create a temporary substring only for attribute parsing (limited for safety)
|
|
724
|
+
const searchStr = fullHtml.substring(currentPos, extractEndPos);
|
|
725
|
+
attr = searchStr.match(attribute);
|
|
726
|
+
|
|
727
|
+
// If input was limited and there’s a match, check if the value might be truncated
|
|
728
|
+
if (attr) {
|
|
729
|
+
// Check if the attribute value extends beyond our search window
|
|
730
|
+
const attrEnd = attr[0].length;
|
|
731
|
+
// If the match ends near the limit, the value might be truncated
|
|
732
|
+
if (attrEnd > MAX_ATTR_PARSE_LENGTH - 100) {
|
|
733
|
+
// Manually extract this attribute to handle potentially huge value
|
|
743
734
|
const manualMatch = searchStr.match(/^\s*([^\s"'<>/=]+)\s*=\s*/);
|
|
744
735
|
if (manualMatch) {
|
|
745
736
|
const quoteChar = searchStr[manualMatch[0].length];
|
|
746
737
|
if (quoteChar === '"' || quoteChar === "'") {
|
|
747
|
-
|
|
748
|
-
const closeQuote = fullHtml.indexOf(quoteChar, currentPos + manualMatch[0].length + 1);
|
|
738
|
+
const closeQuote = searchStr.indexOf(quoteChar, manualMatch[0].length + 1);
|
|
749
739
|
if (closeQuote !== -1) {
|
|
750
|
-
const fullAttrLen = closeQuote
|
|
740
|
+
const fullAttrLen = closeQuote + 1;
|
|
751
741
|
const numCustomParts = handler.customAttrSurround
|
|
752
742
|
? handler.customAttrSurround.length * NCP
|
|
753
743
|
: 0;
|
|
754
744
|
const baseIndex = 1 + numCustomParts;
|
|
755
745
|
|
|
756
746
|
attr = [];
|
|
757
|
-
attr[0] =
|
|
747
|
+
attr[0] = searchStr.substring(0, fullAttrLen);
|
|
758
748
|
attr[baseIndex] = manualMatch[1]; // Attribute name
|
|
759
|
-
attr[baseIndex + 1] = '='; // customAssign
|
|
760
|
-
const value =
|
|
749
|
+
attr[baseIndex + 1] = '='; // `customAssign` (falls back to "=" for huge attributes)
|
|
750
|
+
const value = searchStr.substring(manualMatch[0].length + 1, closeQuote);
|
|
761
751
|
// Place value at correct index based on quote type
|
|
762
752
|
if (quoteChar === '"') {
|
|
763
753
|
attr[baseIndex + 2] = value; // Double-quoted value
|
|
@@ -770,30 +760,83 @@ export class HTMLParser {
|
|
|
770
760
|
continue;
|
|
771
761
|
}
|
|
772
762
|
}
|
|
763
|
+
// Note: Unquoted attribute values are intentionally not handled here
|
|
764
|
+
// Per HTML spec, unquoted values cannot contain spaces or special chars,
|
|
765
|
+
// making a 20 KB+ unquoted value practically impossible; if encountered,
|
|
766
|
+
// it’s malformed HTML and using the truncated regex match is acceptable
|
|
767
|
+
}
|
|
768
|
+
} else {
|
|
769
|
+
// If attr has no value assign but `=` follows in `fullHtml`,
|
|
770
|
+
// the value would be cut off—reset to trigger manual extraction below
|
|
771
|
+
const numCustomParts = handler.customAttrSurround
|
|
772
|
+
? handler.customAttrSurround.length * NCP
|
|
773
|
+
: 0;
|
|
774
|
+
const baseIndex = 1 + numCustomParts;
|
|
775
|
+
if (attr[baseIndex + 1] === undefined) {
|
|
776
|
+
const posAfterName = currentPos + attrEnd;
|
|
777
|
+
if (/^\s*=/.test(fullHtml.slice(posAfterName, posAfterName + 50))) {
|
|
778
|
+
attr = null;
|
|
779
|
+
}
|
|
773
780
|
}
|
|
774
781
|
}
|
|
775
782
|
}
|
|
776
783
|
|
|
777
784
|
if (!attr) {
|
|
778
|
-
|
|
785
|
+
// If input was limited and there’s no match, try manual extraction
|
|
786
|
+
// This handles cases where quoted attributes exceed `MAX_ATTR_PARSE_LENGTH`
|
|
787
|
+
const manualMatch = searchStr.match(/^\s*([^\s"'<>/=]+)\s*=\s*/);
|
|
788
|
+
if (manualMatch) {
|
|
789
|
+
const quoteChar = searchStr[manualMatch[0].length];
|
|
790
|
+
if (quoteChar === '"' || quoteChar === "'") {
|
|
791
|
+
// Search in the full HTML (not limited substring) for closing quote
|
|
792
|
+
const closeQuote = fullHtml.indexOf(quoteChar, currentPos + manualMatch[0].length + 1);
|
|
793
|
+
if (closeQuote !== -1) {
|
|
794
|
+
const fullAttrLen = closeQuote - currentPos + 1;
|
|
795
|
+
const numCustomParts = handler.customAttrSurround
|
|
796
|
+
? handler.customAttrSurround.length * NCP
|
|
797
|
+
: 0;
|
|
798
|
+
const baseIndex = 1 + numCustomParts;
|
|
799
|
+
|
|
800
|
+
attr = [];
|
|
801
|
+
attr[0] = fullHtml.substring(currentPos, closeQuote + 1);
|
|
802
|
+
attr[baseIndex] = manualMatch[1]; // Attribute name
|
|
803
|
+
attr[baseIndex + 1] = '='; // customAssign
|
|
804
|
+
const value = fullHtml.substring(currentPos + manualMatch[0].length + 1, closeQuote);
|
|
805
|
+
// Place value at correct index based on quote type
|
|
806
|
+
if (quoteChar === '"') {
|
|
807
|
+
attr[baseIndex + 2] = value; // Double-quoted value
|
|
808
|
+
} else {
|
|
809
|
+
attr[baseIndex + 3] = value; // Single-quoted value
|
|
810
|
+
}
|
|
811
|
+
currentPos += fullAttrLen;
|
|
812
|
+
consumed += fullAttrLen;
|
|
813
|
+
match.attrs.push(attr);
|
|
814
|
+
continue;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
779
818
|
}
|
|
780
|
-
|
|
781
|
-
const attrLen = attr[0].length;
|
|
782
|
-
currentPos += attrLen;
|
|
783
|
-
consumed += attrLen;
|
|
784
|
-
match.attrs.push(attr);
|
|
785
819
|
}
|
|
786
820
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
close = matchTagClose(currentPos);
|
|
790
|
-
}
|
|
791
|
-
if (close) {
|
|
792
|
-
match.unarySlash = close.slash;
|
|
793
|
-
consumed += close.len;
|
|
794
|
-
match.advance = consumed;
|
|
795
|
-
return match;
|
|
821
|
+
if (!attr) {
|
|
822
|
+
break;
|
|
796
823
|
}
|
|
824
|
+
|
|
825
|
+
const attrLen = attr[0].length;
|
|
826
|
+
currentPos += attrLen;
|
|
827
|
+
consumed += attrLen;
|
|
828
|
+
match.attrs.push(attr);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
// Check for closing tag (manual scan, regex only for the unusual)
|
|
832
|
+
if (!close) {
|
|
833
|
+
close = matchTagClose(currentPos);
|
|
834
|
+
}
|
|
835
|
+
if (close) {
|
|
836
|
+
match.unarySlash = (close & 1) ? '/' : '';
|
|
837
|
+
consumed += close >> 1;
|
|
838
|
+
match.advance = consumed;
|
|
839
|
+
return match;
|
|
797
840
|
}
|
|
798
841
|
return undefined;
|
|
799
842
|
}
|
|
@@ -964,6 +1007,8 @@ export class HTMLParser {
|
|
|
964
1007
|
if (handler.start) {
|
|
965
1008
|
await handler.start(tagName, attrs, unary, unarySlash);
|
|
966
1009
|
}
|
|
1010
|
+
// Returned so the parse loop can skip lowercasing the name again
|
|
1011
|
+
return lowerTagName;
|
|
967
1012
|
}
|
|
968
1013
|
|
|
969
1014
|
// `needle` must already be lowercase
|
|
@@ -1017,6 +1062,8 @@ export class HTMLParser {
|
|
|
1017
1062
|
handler.end(tagName, []);
|
|
1018
1063
|
}
|
|
1019
1064
|
}
|
|
1065
|
+
// Returned so the parse loop can skip lowercasing the name again
|
|
1066
|
+
return lowerTagName;
|
|
1020
1067
|
}
|
|
1021
1068
|
}
|
|
1022
1069
|
}
|