html-minifier-next 7.6.0 → 8.0.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.js"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW,QAAkB,CAAC;AACpC,QAAA,MAAM,SAAS,QAAkB,CAAC;AAClC,QAAA,MAAM,cAAc,QAAsB,CAAC;AAC3C,QAAA,MAAM,qBAAqB,QAAuB,CAAC;AACnD,QAAA,MAAM,kBAAkB,QAAqB,CAAC;AAC9C,QAAA,MAAM,sBAAsB,QAAqB,CAAC;AAClD,QAAA,MAAM,sBAAsB,QAAc,CAAC;AAC3C,QAAA,MAAM,qBAAqB,QAAkB,CAAC;AAC9C,QAAA,MAAM,yBAAyB,QAA0B,CAAC;AAC1D,QAAA,MAAM,qBAAqB,QAAO,CAAC;AACnC,QAAA,MAAM,aAAa,QAAwB,CAAC;AAC5C,QAAA,MAAM,kBAAkB,QAA+oB,CAAC;AACxqB,QAAA,MAAM,YAAY,QAAO,CAAC;AAC1B,QAAA,MAAM,gBAAgB,QAAgB,CAAC;AACvC,QAAA,MAAM,mBAAmB,QAAkB,CAAC;AAC5C,QAAA,MAAM,eAAe,QAAiC,CAAC;AACvD,QAAA,MAAM,gBAAgB,QAAkB,CAAC;AAKzC,QAAA,MAAM,oCAAoC,aAAqY,CAAC;AAGhb,QAAA,MAAM,oCAAoC,aAAkM,CAAC;AAG7O,QAAA,MAAM,8BAA8B,aAA8C,CAAC;AAGnF,QAAA,MAAM,mBAAmB,aAAoF,CAAC;AAK9G,QAAA,MAAM,eAAe;IACnB,WAAW;IACX,aAAa;IACb,OAAO;IACP,mBAAmB;CACpB,CAAC;AAGF,QAAA,MAAM,WAAW;IACf,IAAI;QAAI,KAAK;;IACb,MAAM;QAAI,IAAI;;IACd,IAAI;QACF,OAAO;QACP,MAAM;;IAER,IAAI;QAA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AE+B,CAAC;AAItD,QAAA,MAAM,sBAAsB,aAA+B,CAAC;AAI5D,OAAO,EAEL,WAAW,EACX,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAEhB,oCAAoC,EACpC,oCAAoC,EACpC,8BAA8B,EAC9B,mBAAmB,EAGnB,eAAe,EACf,WAAW,EAGX,0BAA0B,EAC1B,oBAAoB,EACpB,eAAe,EAGf,eAAe,EACf,cAAc,EACd,iBAAiB,EAGjB,cAAc,EAGd,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,YAAY,EAGZ,gBAAgB,EAChB,sBAAsB,EACvB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.js"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW,QAAkB,CAAC;AACpC,QAAA,MAAM,SAAS,QAAkB,CAAC;AAClC,QAAA,MAAM,cAAc,QAAsB,CAAC;AAC3C,QAAA,MAAM,qBAAqB,QAAuB,CAAC;AACnD,QAAA,MAAM,kBAAkB,QAAqB,CAAC;AAC9C,QAAA,MAAM,sBAAsB,QAAqB,CAAC;AAClD,QAAA,MAAM,sBAAsB,QAAc,CAAC;AAC3C,QAAA,MAAM,qBAAqB,QAAkB,CAAC;AAC9C,QAAA,MAAM,yBAAyB,QAA0B,CAAC;AAC1D,QAAA,MAAM,qBAAqB,QAAO,CAAC;AACnC,QAAA,MAAM,aAAa,QAAwB,CAAC;AAC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AY,EACZ,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,YAAY,EAGZ,sBAAsB,EACvB,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Custom fragment matching
3
+ *
4
+ * `ignoreCustomFragments` patterns nearly always describe the same shape: a literal
5
+ * opening delimiter, an any-character or negated-class body, and a literal closing
6
+ * delimiter, as in `<%[\s\S]*?%>` or `\{\{[^}]*?\}\}`. Such a fragment can be found
7
+ * with `indexOf` in linear time, where running the pattern as a regex costs O(n²)
8
+ * on input that opens fragments it never closes—and can cost far more than that when
9
+ * the pattern itself backtracks. Patterns of other shapes keep running as regexes,
10
+ * one per pattern, so each keeps its own flags.
11
+ */
12
+ export type DelimitedFragment = {
13
+ open: string;
14
+ close: string;
15
+ min: number;
16
+ max: number;
17
+ excluded: RegExp | null;
18
+ };
19
+ export type PatternFragment = {
20
+ search: RegExp;
21
+ anchored: RegExp;
22
+ };
23
+ /**
24
+ * Describe a fragment pattern as literal delimiters around an any-character body
25
+ * @param {RegExp} pattern
26
+ * @returns {DelimitedFragment | null} Null when the pattern has another shape, which
27
+ * the caller answers by running it as a regex
28
+ */
29
+ declare function toDelimitedFragment(pattern: RegExp): DelimitedFragment | null;
30
+ /**
31
+ * Prepare a fragment pattern for matching, by scanning where the shape allows it
32
+ * @param {RegExp} pattern
33
+ * @returns {DelimitedFragment | PatternFragment}
34
+ */
35
+ declare function toFragment(pattern: RegExp): DelimitedFragment | PatternFragment;
36
+ /**
37
+ * Replace runs of custom fragments, and the whitespace padding them
38
+ * @param {string} value - Document to scan
39
+ * @param {(DelimitedFragment | PatternFragment)[]} fragments - In the order the patterns
40
+ * were given, since the earliest match wins and ties go to the pattern listed first
41
+ * @param {(match: string) => string} replacer - Called with each match, as `replace` would
42
+ * @returns {string}
43
+ */
44
+ declare function replaceCustomFragments(value: string, fragments: (DelimitedFragment | PatternFragment)[], replacer: (match: string) => string): string;
45
+ export { toDelimitedFragment, toFragment, replaceCustomFragments };
46
+ //# sourceMappingURL=fragments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragments.d.ts","sourceRoot":"","sources":["../../../src/lib/fragments.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAaA,YAA4F,iBAAiB,GAAnG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAC,CAI1F;AAAA,YAA8C,eAAe,GAAnD;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAE9C;AAmCD;;;;;GAKG;AACH,iBAAS,mBAAmB,CAAC,OAAO,EAJzB,MAIyB,GAHvB,iBAAiB,GAAG,IAAI,CAwBpC;AAED;;;;GAIG;AACH,iBAAS,UAAU,CAAC,OAAO,EAHhB,MAGgB,GAFd,iBAAiB,GAAG,eAAe,CAS/C;AAED;;;;;;;GAOG;AACH,iBAAS,sBAAsB,CAAC,KAAK,EAN1B,MAM0B,EAAE,SAAS,EALrC,CAAC,iBAAiB,GAAG,eAAe,CAAC,EAKA,EAAE,QAAQ,EAH/C,CAAC,KAAK,EAAE,MAAM,KAAK,MAG4B,GAF7C,MAAM,CAwJlB;AAID,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,sBAAsB,EACvB,CAAC"}
@@ -1,202 +1,25 @@
1
- declare const optionDefinitions: {
2
- cacheCSS: {
3
- description: string;
4
- type: string;
5
- };
6
- cacheJS: {
7
- description: string;
8
- type: string;
9
- };
10
- cacheSVG: {
11
- description: string;
12
- type: string;
13
- };
14
- caseSensitive: {
15
- description: string;
16
- type: string;
17
- };
18
- collapseAttributeWhitespace: {
19
- description: string;
20
- type: string;
21
- };
22
- collapseBooleanAttributes: {
23
- description: string;
24
- type: string;
25
- };
26
- collapseInlineTagWhitespace: {
27
- description: string;
28
- type: string;
29
- };
30
- collapseWhitespace: {
31
- description: string;
32
- type: string;
33
- };
34
- conservativeCollapse: {
35
- description: string;
36
- type: string;
37
- };
38
- continueOnMinifyError: {
39
- description: string;
40
- descriptionAffirmative: string;
41
- type: string;
42
- };
43
- continueOnParseError: {
44
- description: string;
45
- type: string;
46
- };
47
- customAttrAssign: {
48
- description: string;
49
- type: string;
50
- };
51
- customAttrCollapse: {
52
- description: string;
53
- type: string;
54
- };
55
- customAttrSurround: {
56
- description: string;
57
- type: string;
58
- };
59
- customEventAttributes: {
60
- description: string;
61
- type: string;
62
- };
63
- customFragmentQuantifierLimit: {
64
- description: string;
65
- type: string;
66
- };
67
- decodeEntities: {
68
- description: string;
69
- type: string;
70
- };
71
- ignoreCustomComments: {
72
- description: string;
73
- type: string;
74
- };
75
- ignoreCustomFragments: {
76
- description: string;
77
- type: string;
78
- };
79
- includeAutoGeneratedTags: {
80
- description: string;
81
- type: string;
82
- };
83
- inlineCustomElements: {
84
- description: string;
85
- type: string;
86
- };
87
- keepClosingSlash: {
88
- description: string;
89
- type: string;
90
- };
91
- maxInputLength: {
92
- description: string;
93
- type: string;
94
- };
95
- maxLineLength: {
96
- description: string;
97
- type: string;
98
- };
99
- mergeScripts: {
100
- description: string;
101
- type: string;
102
- };
103
- minifyCSS: {
104
- description: string;
105
- type: string;
106
- };
107
- minifyJS: {
108
- description: string;
109
- type: string;
110
- };
111
- minifySVG: {
112
- description: string;
113
- type: string;
114
- };
115
- minifyURLs: {
116
- description: string;
117
- type: string;
118
- };
119
- noNewlinesBeforeTagClose: {
120
- description: string;
121
- type: string;
122
- };
123
- partialMarkup: {
124
- description: string;
125
- type: string;
126
- };
127
- preserveLineBreaks: {
128
- description: string;
129
- type: string;
130
- };
131
- preventAttributesEscaping: {
132
- description: string;
133
- type: string;
134
- };
135
- processScripts: {
136
- description: string;
137
- type: string;
138
- };
139
- quoteCharacter: {
140
- description: string;
141
- type: string;
142
- };
143
- removeAttributeQuotes: {
144
- description: string;
145
- type: string;
146
- };
147
- removeComments: {
148
- description: string;
149
- type: string;
150
- };
151
- removeDefaultTypeAttributes: {
152
- description: string;
153
- type: string;
154
- };
155
- removeEmptyAttributes: {
156
- description: string;
157
- type: string;
158
- };
159
- removeEmptyElements: {
160
- description: string;
161
- type: string;
162
- };
163
- removeEmptyElementsExcept: {
164
- description: string;
165
- type: string;
166
- };
167
- removeOptionalTags: {
168
- description: string;
169
- type: string;
170
- };
171
- removeRedundantAttributes: {
172
- description: string;
173
- type: string;
174
- };
175
- removeTagWhitespace: {
176
- description: string;
177
- type: string;
178
- };
179
- removeUnusedCSS: {
180
- description: string;
181
- type: string;
182
- };
183
- sortAttributes: {
184
- description: string;
185
- type: string;
186
- };
187
- sortClassNames: {
188
- description: string;
189
- type: string;
190
- };
191
- trimCustomFragments: {
192
- description: string;
193
- type: string;
194
- };
195
- useShortDoctype: {
196
- description: string;
197
- type: string;
198
- };
1
+ export type OptionDefinition = {
2
+ /**
3
+ * Help text, phrased for the option’s primary CLI form
4
+ */
5
+ description: string;
6
+ /**
7
+ * Help text for what enabling the option does, where `description` describes the negated form
8
+ */
9
+ descriptionAffirmative?: string;
10
+ /**
11
+ * Key into the parser and JSON Schema type maps in cli.js and scripts/build-schema.js
12
+ */
13
+ type: string;
199
14
  };
15
+ /**
16
+ * @typedef {object} OptionDefinition
17
+ * @property {string} description Help text, phrased for the option’s primary CLI form
18
+ * @property {string} [descriptionAffirmative] Help text for what enabling the option does, where `description` describes the negated form
19
+ * @property {string} type Key into the parser and JSON Schema type maps in cli.js and scripts/build-schema.js
20
+ */
21
+ /** @type {Record<string, OptionDefinition>} */
22
+ declare const optionDefinitions: Record<string, OptionDefinition>;
200
23
  declare const optionDefaults: {
201
24
  continueOnMinifyError: boolean;
202
25
  ignoreCustomComments: RegExp[];
@@ -1 +1 @@
1
- {"version":3,"file":"option-definitions.d.ts","sourceRoot":"","sources":["../../../src/lib/option-definitions.js"],"names":[],"mappings":"AAEA,QAAA,MAAM,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,WAAW;QACX,IAAI;;IAEN,cAAc;QACZ,WAAW;QACX,IAAI;;IAEN,cAAc;QACZ,WAAW;QACX,IAAI;;IAEN,qBAAqB;QACnB,WAAW;QACX,IAAI;;IAEN,cAAc;QACZ,WAAW;QACX,IAAI;;IAEN,2BAA2B;QACzB,WAAW;QACX,IAAI;;IAEN,qBAAqB;QACnB,WAAW;QACX,IAAI;;IAEN,mBAAmB;QACjB,WAAW;QACX,IAAI;;IAEN,yBAAyB;QACvB,WAAW;QACX,IAAI;;IAEN,kBAAkB;QAChB,WAAW;QACX,IAAI;;IAEN,yBAAyB;QACvB,WAAW;QACX,IAAI;;IAEN,mBAAmB;QACjB,WAAW;QACX,IAAI;;IAEN,eAAe;QACb,WAAW;QACX,IAAI;;IAEN,cAAc;QACZ,WAAW;QACX,IAAI;;IAEN,cAAc;QACZ,WAAW;QACX,IAAI;;IAEN,mBAAmB;QACjB,WAAW;QACX,IAAI;;IAEN,eAAe;QACb,WAAW;QACX,IAAI;;CAEP,CAAC;AAEF,QAAA,MAAM,cAAc;IAClB,qBAAqB;IACrB,oBAAoB;IAIpB,qBAAqB;IAIrB,wBAAwB;CACzB,CAAC;AAIF,OAAO,EACL,iBAAiB,EACjB,cAAc,EACf,CAAC"}
1
+ {"version":3,"file":"option-definitions.d.ts","sourceRoot":"","sources":["../../../src/lib/option-definitions.js"],"names":[],"mappings":"AAGG,YAAkB,gBAAgB,GAClC;;;;IAAmB,WAAW,EAAnB,MAAM,CACjB;;;;IAAoB,sBAAsB,AAA1C,CACA,EADW,MAAM,CACjB;;;;IAAmB,IAAI,EAAZ,MAAM,CACnB;CAAA,CAAA;AALD;;;;;GAKG;AAEH,+CAA+C;AAC/C,QAAA,MAAM,iBAAiB,EADZ,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAuMzC,CAAC;AAEF,QAAA,MAAM,cAAc;IAClB,qBAAqB;IACrB,oBAAoB;IAIpB,qBAAqB;IAIrB,wBAAwB;CACzB,CAAC;AAIF,OAAO,EACL,iBAAiB,EACjB,cAAc,EACf,CAAC"}
@@ -44,7 +44,7 @@ export type ProcessedOptions = Omit<MinifierOptions, 'preset' | 'canCollapseWhit
44
44
  */
45
45
  /**
46
46
  * Options object produced by `processOptions` and consumed by `minifyHTML` and
47
- * the `lib/` helpers; normalization guarantees that the function-valued options
47
+ * the lib/ helpers; normalization guarantees that the function-valued options
48
48
  * below are always present (defaulting to identity/built-in functions), and
49
49
  * minification adds writable internal state on top of the public options
50
50
  * (set on prototype-chain forks during SVG/MathML namespace transitions)
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/lib/options.js"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAsG,MAAM,YAAY,CAAC;AAQjI,OAAQ,KAAA,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AASrE,YAA4D,UAAU,GAA5D;IAAC,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAC,CAAY;AAOtE,YAA6C,SAAS,GAA5C;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAC,CAAW;AAUtD,YAgBG,gBAAgB,GAhBT,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,uBAAuB,GAAG,mBAAmB,GAAG,sBAAsB,GAAG,KAAK,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,iBAAiB,CAAC,GAAG;IACvM,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/B,GAAG,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC;IAC/B,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,qBAAqB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,CA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CAC/B,CAAkB;AA1CtB,2EAA2E;AAI3E;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,wCAAwC;AACxC,iBAAS,qBAAqB,CAAC,OAAO,EAD1B,gBAC0B,WAUrC;AAwCD;;;;GAIG;AACH,QAAA,MAAM,cAAc,iBAJT,eAAe,mGACf;IAAC,eAAe,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;IAAC,aAAa,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,GAAG,SAAS,CAAA;CAAC,KAC5O,gBAmhBZ,CAAC;AAIF,OAAO,EACL,qBAAqB,EACrB,cAAc,EACf,CAAC"}
@@ -2,16 +2,17 @@
2
2
  * Collect the class names and IDs a document references.
3
3
  *
4
4
  * Style sheet contents are excluded, so that a style sheet never counts as
5
- * evidence for its own selectors. Over-collecting is safe here (a symbol wrongly
6
- * considered used is merely kept), under-collecting is not.
5
+ * evidence for its own selectors. An `iframe srcdoc` value is not scanned
6
+ * either: It holds a document of its own, minified against its own symbol set.
7
+ * Over-collecting is safe here (a symbol wrongly considered used is merely
8
+ * kept), under-collecting is not.
7
9
  *
8
10
  * @param {string} html - Raw document markup
9
11
  * @param {boolean} includeScripts - Also treat identifiers inside inline `script` elements as used
10
12
  * @param {((text: string) => string)} [decode] - Resolves character references in attribute values
11
- * @param {number} [depth] - Nesting level, counted through `srcdoc`
12
13
  * @returns {Set<string>} Symbols to keep
13
14
  */
14
- declare function collectUsedSymbols(html: string, includeScripts: boolean, decode?: ((text: string) => string), depth?: number): Set<string>;
15
+ declare function collectUsedSymbols(html: string, includeScripts: boolean, decode?: ((text: string) => string)): Set<string>;
15
16
  /**
16
17
  * Determine which class/ID symbols a style sheet defines but the document never references.
17
18
  * @param {string} css - Style sheet contents
@@ -1 +1 @@
1
- {"version":3,"file":"unused-css.d.ts","sourceRoot":"","sources":["../../../src/lib/unused-css.js"],"names":[],"mappings":"AA2KA;;;;;;;;;;;;GAYG;AACH,iBAAS,kBAAkB,CAAC,IAAI,EANrB,MAMqB,EAAE,cAAc,EALrC,OAKqC,EAAE,MAAM,AAJrD,CACA,EADQ,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAIoB,EAAE,KAAK,AAH5D,CACA,EADQ,MAGwD,GAFtD,GAAG,CAAC,MAAM,CAAC,CAyGvB;AAED;;;;;;GAMG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EALnB,MAKmB,EAAE,IAAI,EAJzB,GAAG,CAAC,MAAM,CAIe,EAAE,QAAQ,EAHnC,KAAK,CAAC,MAAM,GAAG,MAAM,CAGc,GAFjC,MAAM,EAAE,CAuCpB;AAID;;;;;;;;;;GAUG;AACH,iBAAS,yBAAyB,CAAC,MAAM,EAJ9B,OAAO,GAAG;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAC,GAAG,SAIrC,EAAE,IAAI,AAH5C,CACA,EADQ,CAAC,OAAO,EAAE,MAAM,KAAK,OAGe,GAFlC;IAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,GAAG,IAAI,CAyCvE;AAED,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EAC1B,CAAC"}
1
+ {"version":3,"file":"unused-css.d.ts","sourceRoot":"","sources":["../../../src/lib/unused-css.js"],"names":[],"mappings":"AAwKA;;;;;;;;;;;;;GAaG;AACH,iBAAS,kBAAkB,CAAC,IAAI,EALrB,MAKqB,EAAE,cAAc,EAJrC,OAIqC,EAAE,MAAM,AAHrD,CACA,EADQ,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAGoB,GAF3C,GAAG,CAAC,MAAM,CAAC,CA0FvB;AAED;;;;;;GAMG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EALnB,MAKmB,EAAE,IAAI,EAJzB,GAAG,CAAC,MAAM,CAIe,EAAE,QAAQ,EAHnC,KAAK,CAAC,MAAM,GAAG,MAAM,CAGc,GAFjC,MAAM,EAAE,CAuCpB;AAID;;;;;;;;;;GAUG;AACH,iBAAS,yBAAyB,CAAC,MAAM,EAJ9B,OAAO,GAAG;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAC,GAAG,SAIrC,EAAE,IAAI,AAH5C,CACA,EADQ,CAAC,OAAO,EAAE,MAAM,KAAK,OAGe,GAFlC;IAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,GAAG,IAAI,CAyCvE;AAED,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EAC1B,CAAC"}
@@ -51,6 +51,23 @@ declare function lowercase(value: string): string;
51
51
  declare function replaceAsync(str: string, regex: RegExp, asyncFn: Function): Promise<string>;
52
52
  /** @param {string | RegExp} value */
53
53
  declare function parseRegExp(value: string | RegExp): RegExp | undefined;
54
+ /**
55
+ * A pattern’s source, rewritten to match the way its own flags make it match, for
56
+ * embedding in a larger regex that cannot carry them. `i` and `s` fit into a
57
+ * source; `m`, `u`, and `v` do not, and are left to the pattern it joins. Where
58
+ * `i` cannot be written in—a backreference, a range outside ASCII, a range that
59
+ * spans letters without being one—the source stands as it is, matching less than
60
+ * the pattern would rather than more.
61
+ * @param {RegExp} pattern
62
+ * @returns {string}
63
+ */
64
+ declare function embedSource(pattern: RegExp): string;
65
+ /**
66
+ * @param {string} source - Regex source to judge
67
+ * @returns {string | null} What makes the pattern a backtracking risk, phrased
68
+ * to follow the pattern itself, or `null` where it is none
69
+ */
70
+ declare function describeQuantifierRisk(source: string): string | null;
54
71
  /**
55
72
  * Find the index of the `>` that closes an opening tag, correctly skipping
56
73
  * over quoted attribute values (which may contain `>`).
@@ -59,5 +76,5 @@ declare function parseRegExp(value: string | RegExp): RegExp | undefined;
59
76
  * @returns {number} Index of the closing `>`, or -1 if not found
60
77
  */
61
78
  declare function findTagEnd(html: string, pos: number): number;
62
- export { stableStringify, findTagEnd, LRU, MAX_CACHE_ENTRY_SIZE, hashContent, uniqueId, identity, isThenable, lowercase, replaceAsync, parseRegExp };
79
+ export { stableStringify, findTagEnd, LRU, MAX_CACHE_ENTRY_SIZE, hashContent, uniqueId, identity, isThenable, lowercase, replaceAsync, parseRegExp, embedSource, describeQuantifierRisk };
63
80
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,iBAAS,eAAe,CAAC,GAAG,EAHjB,OAGiB,GAFf,MAAM,CAYlB;AAID,cAAM,GAAG;IAEA,KAAK;IACL,IAAI;IACJ,IAAI;IACT,mCAAmC;IAC9B,GAAG,EADG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAJjC,YAAY,KAAK,SAAM,EAMtB;IACD,0BAA0B;IAC1B,GAAG,CAAC,GAAG,EADK,MACL,WAUN;IACD;;;OAGG;IACH,GAAG,CAAC,GAAG,EAHI,MAGJ,EAAE,KAAK,EAFH,OAEG,QAOb;IACD,0BAA0B;IAC1B,MAAM,CAAC,GAAG,EADE,MACF,QAA2B;IACrC,6EAA6E;IAC7E,KAAK,IADS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAA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,GAFhB,MAAM,CAelB;AAID,OAAO,EACL,eAAe,EACf,UAAU,EACV,GAAG,EACH,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,sBAAsB,EACvB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  declare class Sorter {
2
- /** @type {string[]} */
3
- keys: string[];
2
+ /** @type {Map<string, number>} */
3
+ rank: Map<string, number>;
4
4
  /** @type {Map<string, Sorter>} */
5
5
  sorterMap: Map<string, Sorter>;
6
6
  constructor();
@@ -1 +1 @@
1
- {"version":3,"file":"tokenchain.d.ts","sourceRoot":"","sources":["../../src/tokenchain.js"],"names":[],"mappings":"AAAA,cAAM,MAAM;IAER,uBAAuB;IAClB,IAAI,EADE,MAAM,EAAE;IAEnB,kCAAkC;IAC7B,SAAS,EADH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAHhC,cAKC;IAED;;;;OAIG;IACH,IAAI,CAAC,MAAM,EAJA,MAAM,EAIN,EAAE,SAAS,GAHX,MAGe,GAFb,MAAM,EAAE,CAiCpB;CACF;AAED,cAAM,UAAU;IAEZ,mEAAmE;IAC9D,GAAG,EADG,GAAG,CAAC,MAAM,EAAE;QAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,CAAC;IADjE,cAGC;IAED,+BAA+B;IAC/B,GAAG,CAAC,MAAM,EADE,MAAM,EACR,QAST;IAED,YAAY,WA+CX;CACF;eAEc,UAAU"}
1
+ {"version":3,"file":"tokenchain.d.ts","sourceRoot":"","sources":["../../src/tokenchain.js"],"names":[],"mappings":"AAAA,cAAM,MAAM;IAIR,kCAAkC;IAC7B,IAAI,EADE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAE9B,kCAAkC;IAC7B,SAAS,EADH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IALhC,cAOC;IAED;;;;OAIG;IACH,IAAI,CAAC,MAAM,EAJA,MAAM,EAIN,EAAE,SAAS,GAHX,MAGe,GAFb,MAAM,EAAE,CAsCpB;CACF;AAED,cAAM,UAAU;IAEZ,mEAAmE;IAC9D,GAAG,EADG,GAAG,CAAC,MAAM,EAAE;QAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,CAAC;IADjE,cAGC;IAED,+BAA+B;IAC/B,GAAG,CAAC,MAAM,EADE,MAAM,EACR,QAST;IAED,YAAY,WA+CX;CACF;eAEc,UAAU"}
@@ -117,11 +117,6 @@
117
117
  "type": "string"
118
118
  }
119
119
  },
120
- "customFragmentQuantifierLimit": {
121
- "description": "Set maximum quantifier limit for custom fragments to prevent ReDoS attacks (default: 200)",
122
- "type": "integer",
123
- "minimum": 0
124
- },
125
120
  "decodeEntities": {
126
121
  "description": "Use direct Unicode characters whenever possible",
127
122
  "type": "boolean"
@@ -298,6 +293,10 @@
298
293
  "description": "Trim whitespace around custom fragments (`--ignore-custom-fragments`)",
299
294
  "type": "boolean"
300
295
  },
296
+ "strictCustomFragments": {
297
+ "description": "Reject `ignoreCustomFragments` patterns that risk catastrophic backtracking (rather than warning about them)",
298
+ "type": "boolean"
299
+ },
301
300
  "useShortDoctype": {
302
301
  "description": "Replaces the doctype with the short HTML doctype",
303
302
  "type": "boolean"
package/package.json CHANGED
@@ -95,5 +95,5 @@
95
95
  },
96
96
  "type": "module",
97
97
  "types": "dist/types/htmlminifier.d.ts",
98
- "version": "7.6.0"
98
+ "version": "8.0.0"
99
99
  }
@@ -55,6 +55,7 @@ import {
55
55
  } from './lib/content.js';
56
56
 
57
57
  import { processOptions } from './lib/options.js';
58
+ import { toFragment, replaceCustomFragments } from './lib/fragments.js';
58
59
 
59
60
  /** @import { ProcessedOptions } from './lib/options.js' */
60
61
 
@@ -63,7 +64,7 @@ import { processOptions } from './lib/options.js';
63
64
  /**
64
65
  * @typedef {Object} HTMLAttribute
65
66
  * Representation of an attribute from the HTML parser.
66
- * Internal counterpart: `HTMLAttribute` in `lib/attributes.js`—keep in sync.
67
+ * Internal counterpart: `HTMLAttribute` in lib/attributes.js—keep in sync.
67
68
  *
68
69
  * @prop {string} name
69
70
  * @prop {string} [value]
@@ -196,11 +197,13 @@ import { processOptions } from './lib/options.js';
196
197
  *
197
198
  * Default: `[/^on[a-z]{3,}$/]`
198
199
  *
199
- * @prop {number} [customFragmentQuantifierLimit]
200
- * Limits the quantifier used when building a safe regex for custom
201
- * fragments to avoid ReDoS. See source use for details.
200
+ * @prop {boolean} [strictCustomFragments]
201
+ * Rejects `ignoreCustomFragments` patterns that risk catastrophic backtracking,
202
+ * rather than warning about them: those that compound quantifiers or alternation
203
+ * (`(a+)+`, `(a|b)*`), those that repeat the same unbounded atom twice in a row
204
+ * (`.*.*`), and those too long or too deeply nested to analyze at all.
202
205
  *
203
- * Default: `200`
206
+ * Default: `false`
204
207
  *
205
208
  * @prop {boolean} [decodeEntities]
206
209
  * When true, decodes HTML entities in text and attributes before
@@ -826,13 +829,12 @@ async function createSortFns(value, options, uidIgnore, uidAttr, ignoredMarkupCh
826
829
  const originalContinueOnParseError = options.continueOnParseError;
827
830
  options.continueOnParseError = true;
828
831
 
829
- // Pre-compile regex patterns for UID replacement and custom fragments
832
+ // Pre-compile the UID replacement pattern, and read the fragments the way the
833
+ // main path does, so each keeps its own flags
830
834
  const uidReplacePattern = uidIgnore && ignoredMarkupChunks
831
835
  ? new RegExp('<!--' + uidIgnore + '(\\d+)-->', 'g')
832
836
  : null;
833
- const customFragmentPattern = options.ignoreCustomFragments && options.ignoreCustomFragments.length > 0
834
- ? new RegExp('(' + options.ignoreCustomFragments.map(re => re.source).join('|') + ')', 'g')
835
- : null;
837
+ const customFragments = (options.ignoreCustomFragments || []).map(toFragment);
836
838
 
837
839
  try {
838
840
  // Expand UID tokens back to the original content for frequency analysis
@@ -852,8 +854,8 @@ async function createSortFns(value, options, uidIgnore, uidAttr, ignoredMarkupCh
852
854
  // because HTML comments in opening tags prevent proper attribute parsing;
853
855
  // removed with a space to preserve attribute boundaries
854
856
  let scanValue = firstPassOutput;
855
- if (customFragmentPattern) {
856
- scanValue = firstPassOutput.replace(customFragmentPattern, ' ');
857
+ if (customFragments.length) {
858
+ scanValue = replaceCustomFragments(firstPassOutput, customFragments, () => ' ');
857
859
  }
858
860
 
859
861
  await scan(scanValue);
@@ -1057,63 +1059,46 @@ async function minifyHTML(value, options, partialMarkup) {
1057
1059
  await createSortFns(value, options, uidIgnore ?? '', uidAttr ?? '', ignoredMarkupChunks);
1058
1060
  }
1059
1061
 
1060
- const customFragments = (options.ignoreCustomFragments || []).map(function (/** @type {RegExp} */ re) {
1061
- return re.source;
1062
- });
1062
+ const customFragments = (options.ignoreCustomFragments || []).map(toFragment);
1063
1063
  if (customFragments.length) {
1064
- // Safe approach: Use bounded quantifiers instead of unlimited ones to prevent ReDoS
1065
- const maxQuantifier = options.customFragmentQuantifierLimit || 200;
1066
- const whitespacePattern = `\\s{0,${maxQuantifier}}`;
1067
-
1068
- // Fast path: The padded replace below is costly on large inputs because the
1069
- // `\s{0,N}` padding makes the regex engine consume and backtrack at every
1070
- // whitespace run; since the padding is optional and the fragment group requires
1071
- // at least one match, a single unpadded probe that finds nothing proves the
1072
- // replace would be a no-op—so skip it entirely
1073
- const reFragmentProbe = new RegExp('(?:' + customFragments.join('|') + ')');
1074
- if (reFragmentProbe.test(value)) {
1075
- // Use bounded quantifiers to prevent ReDoS—this approach prevents exponential backtracking
1076
- const reCustomIgnore = new RegExp(
1077
- whitespacePattern + '(?:' + customFragments.join('|') + '){1,' + maxQuantifier + '}' + whitespacePattern,
1078
- 'g'
1079
- );
1080
- // Temporarily replace custom ignored fragments with unique attributes
1081
- value = value.replace(reCustomIgnore, function (match) {
1082
- if (!uidAttr) {
1083
- uidAttr = uniqueId(value);
1084
- uidPattern = new RegExp('(\\s*)' + uidAttr + '([0-9]+)' + uidAttr + '(\\s*)', 'g');
1085
- uidAttrLeadingPattern = new RegExp('^\\s*' + uidAttr + '(\\d+)' + uidAttr);
1086
-
1087
- if (options.minifyCSS !== identity) {
1088
- options.minifyCSS = (function (/** @type {ProcessedOptions['minifyCSS']} */ fn) {
1089
- return function (/** @type {string} */ text, /** @type {string | undefined} */ type, /** @type {ProcessedOptions['cssContext']} */ context) {
1090
- text = text.replace(/** @type {RegExp} */ (uidPattern), function (/** @type {string} */ _match, /** @type {string} */ _prefix, /** @type {string} */ index) {
1091
- const chunks = ignoredCustomMarkupChunks[+index];
1092
- return (chunks?.[1] ?? '') + uidAttr + index + uidAttr + (chunks?.[2] ?? '');
1093
- });
1094
-
1095
- return fn(text, type, context);
1096
- };
1097
- })(options.minifyCSS);
1098
- }
1064
+ // Temporarily replace custom ignored fragments with unique attributes
1065
+ const replaceFragment = function (/** @type {string} */ match) {
1066
+ if (!uidAttr) {
1067
+ uidAttr = uniqueId(value);
1068
+ uidPattern = new RegExp('(\\s*)' + uidAttr + '([0-9]+)' + uidAttr + '(\\s*)', 'g');
1069
+ uidAttrLeadingPattern = new RegExp('^\\s*' + uidAttr + '(\\d+)' + uidAttr);
1070
+
1071
+ if (options.minifyCSS !== identity) {
1072
+ options.minifyCSS = (function (/** @type {ProcessedOptions['minifyCSS']} */ fn) {
1073
+ return function (/** @type {string} */ text, /** @type {string | undefined} */ type, /** @type {ProcessedOptions['cssContext']} */ context) {
1074
+ text = text.replace(/** @type {RegExp} */ (uidPattern), function (/** @type {string} */ _match, /** @type {string} */ _prefix, /** @type {string} */ index) {
1075
+ const chunks = ignoredCustomMarkupChunks[+index];
1076
+ return (chunks?.[1] ?? '') + uidAttr + index + uidAttr + (chunks?.[2] ?? '');
1077
+ });
1099
1078
 
1100
- if (options.minifyJS !== identity) {
1101
- options.minifyJS = (function (/** @type {ProcessedOptions['minifyJS']} */ fn) {
1102
- return function (/** @type {string} */ text, /** @type {boolean | undefined} */ inline, /** @type {boolean | undefined} */ isModule) {
1103
- return fn(text.replace(/** @type {RegExp} */ (uidPattern), function (/** @type {string} */ _match, /** @type {string} */ _prefix, /** @type {string} */ index) {
1104
- const chunks = ignoredCustomMarkupChunks[+index];
1105
- return (chunks?.[1] ?? '') + uidAttr + index + uidAttr + (chunks?.[2] ?? '');
1106
- }), inline, isModule);
1107
- };
1108
- })(options.minifyJS);
1109
- }
1079
+ return fn(text, type, context);
1080
+ };
1081
+ })(options.minifyCSS);
1110
1082
  }
1111
1083
 
1112
- const token = uidAttr + ignoredCustomMarkupChunks.length + uidAttr;
1113
- ignoredCustomMarkupChunks.push(/^(\s*)[\s\S]*?(\s*)$/.exec(match));
1114
- return '\t' + token + '\t';
1115
- });
1116
- }
1084
+ if (options.minifyJS !== identity) {
1085
+ options.minifyJS = (function (/** @type {ProcessedOptions['minifyJS']} */ fn) {
1086
+ return function (/** @type {string} */ text, /** @type {boolean | undefined} */ inline, /** @type {boolean | undefined} */ isModule) {
1087
+ return fn(text.replace(/** @type {RegExp} */ (uidPattern), function (/** @type {string} */ _match, /** @type {string} */ _prefix, /** @type {string} */ index) {
1088
+ const chunks = ignoredCustomMarkupChunks[+index];
1089
+ return (chunks?.[1] ?? '') + uidAttr + index + uidAttr + (chunks?.[2] ?? '');
1090
+ }), inline, isModule);
1091
+ };
1092
+ })(options.minifyJS);
1093
+ }
1094
+ }
1095
+
1096
+ const token = uidAttr + ignoredCustomMarkupChunks.length + uidAttr;
1097
+ ignoredCustomMarkupChunks.push(/^(\s*)[\s\S]*?(\s*)$/.exec(match));
1098
+ return '\t' + token + '\t';
1099
+ };
1100
+
1101
+ value = replaceCustomFragments(value, customFragments, replaceFragment);
1117
1102
  }
1118
1103
 
1119
1104
  function canCollapseWhitespace(/** @type {string} */ tag, /** @type {HTMLAttribute[]} */ attrs) {
package/src/htmlparser.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
6
6
  */
7
7
 
8
- import { isThenable } from './lib/utils.js';
8
+ import { isThenable, embedSource } from './lib/utils.js';
9
9
 
10
10
  /** @import { HTMLAttribute } from './lib/attributes.js' */
11
11
 
@@ -141,9 +141,9 @@ function buildAttrRegex(handler) {
141
141
  throw new Error('`customAttrSurround` entries must be `[RegExp, RegExp]` pairs');
142
142
  }
143
143
  attrClauses[i] = '(?:' +
144
- '(' + pair[0].source + ')\\s*' +
144
+ '(' + embedSource(pair[0]) + ')\\s*' +
145
145
  pattern +
146
- '\\s*(' + pair[1].source + ')' +
146
+ '\\s*(' + embedSource(pair[1]) + ')' +
147
147
  ')';
148
148
  }
149
149
  attrClauses.push('(?:' + pattern + ')');
@@ -180,7 +180,7 @@ function joinSingleAttrAssigns(handler) {
180
180
  return singleAttrAssigns.concat(
181
181
  handler.customAttrAssign || []
182
182
  ).map(function (assign) {
183
- return '(?:' + assign.source + ')';
183
+ return '(?:' + embedSource(assign) + ')';
184
184
  }).join('|');
185
185
  }
186
186