html-minifier-next 6.1.2 → 6.1.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # HTML Minifier Next
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/html-minifier-next.svg)](https://www.npmjs.com/package/html-minifier-next) [![Build status](https://github.com/j9t/html-minifier-next/workflows/Tests/badge.svg)](https://github.com/j9t/html-minifier-next/actions) [![Socket](https://badge.socket.dev/npm/package/html-minifier-next)](https://socket.dev/npm/package/html-minifier-next)
3
+ [![npm version](https://img.shields.io/npm/v/html-minifier-next.svg)](https://www.npmjs.com/package/html-minifier-next) [![Build status](https://github.com/j9t/html-minifier-next/workflows/Tests/badge.svg)](https://github.com/j9t/html-minifier-next/actions) [![Socket](https://badge.socket.dev/npm/package/html-minifier-next)](https://socket.dev/npm/package/html-minifier-next) [![GitHub Sponsors](https://badgen.net/static/Support/Open%20Source/cyan)](https://github.com/j9t/html-minifier-next?sponsor=1)
4
4
 
5
5
  Your web page optimization precision tool: HTML Minifier Next (HMN) is a **super-configurable, well-tested, JavaScript-based HTML minifier** able to also handle in-document CSS, JavaScript, and SVG minification.
6
6
 
@@ -603,4 +603,12 @@ Parameters:
603
603
 
604
604
  ## Acknowledgements
605
605
 
606
- With many thanks to all the previous authors of HTML Minifier, especially [Juriy “kangax” Zaytsev](https://github.com/kangax), and to everyone who helped make this new edition better, particularly [Daniel Ruf](https://github.com/DanielRuf) and [Jonas Geiler](https://github.com/jonasgeiler).
606
+ With many thanks to all the previous authors of HTML Minifier, especially [Juriy “kangax” Zaytsev](https://github.com/kangax), and to everyone who helped make this new edition better, particularly [Daniel Ruf](https://github.com/DanielRuf) and [Jonas Geiler](https://github.com/jonasgeiler).
607
+
608
+ ***
609
+
610
+ You might like some of my other work:
611
+
612
+ * Optimization tools: HTML Minifier Next · [ObsoHTML](https://github.com/j9t/obsohtml) · [Image Guard](https://github.com/j9t/image-guard) · [Compressor.js Next](https://github.com/j9t/compressorjs-next) · [.htaccess Punk](https://github.com/j9t/htaccess-punk)
613
+ * Defense tools: [IA Defensa](https://iadefensa.com/solutions/)
614
+ * Resources for quality web development: [Articles](https://meiert.com/topics/development/) · [Books](https://meiert.com/topics/books/) (including [_On Web Development_](https://meiert.com/blog/on-web-development-2/)) · [News](https://frontenddogma.com/) · [Terminology](https://webglossary.info/)
@@ -135,9 +135,14 @@ const singleAttrValues = [
135
135
  /"([^"]*)"+/.source,
136
136
  // Attr value, single quotes
137
137
  /'([^']*)'+/.source,
138
- // Attr value, no quotes
138
+ // Attr value, no quotes (strict: excludes `=` per HTML spec)
139
139
  /([^ \t\n\f\r"'`=<>]+)/.source
140
140
  ];
141
+ // Lenient unquoted value pattern for `continueOnParseError`:
142
+ // allows `<`, `=`, and ``` per HTML error-recovery rules
143
+ // (all are parse errors in unquoted-attribute-value state but appended to the value)
144
+ // `"` and `'` remain excluded—permitting them requires broader test coverage
145
+ const singleAttrValueLenientUnquoted = /([^ \t\n\f\r"'>]+)/.source;
141
146
  // https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
142
147
  const qnameCapture = (function () {
143
148
  // https://www.npmjs.com/package/ncname
@@ -203,9 +208,11 @@ function stripDelimited(str, open, close) {
203
208
  }
204
209
 
205
210
  function buildAttrRegex(handler) {
211
+ const unquotedValue = handler.continueOnParseError ? singleAttrValueLenientUnquoted : singleAttrValues[2];
212
+ const attrValues = [singleAttrValues[0], singleAttrValues[1], unquotedValue];
206
213
  let pattern = singleAttrIdentifier.source +
207
214
  '(?:\\s*(' + joinSingleAttrAssigns(handler) + ')' +
208
- '[ \\t\\n\\f\\r]*(?:' + singleAttrValues.join('|') + '))?';
215
+ '[ \\t\\n\\f\\r]*(?:' + attrValues.join('|') + '))?';
209
216
  if (handler.customAttrSurround) {
210
217
  const attrClauses = [];
211
218
  for (let i = handler.customAttrSurround.length - 1; i >= 0; i--) {
@@ -1 +1 @@
1
- {"version":3,"file":"htmlparser.d.ts","sourceRoot":"","sources":["../../src/htmlparser.js"],"names":[],"mappings":"AAgDA,4BAAkE;AAwGlE;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,uBAmmBC;CACF"}
package/package.json CHANGED
@@ -19,11 +19,11 @@
19
19
  "@rollup/plugin-json": "^6.1.0",
20
20
  "@rollup/plugin-node-resolve": "^16.0.3",
21
21
  "@swc/core": "^1.15.21",
22
- "eslint": "^10.1.0",
22
+ "eslint": "^10.2.0",
23
23
  "rollup": "^4.60.0",
24
24
  "rollup-plugin-polyfill-node": "^0.13.0",
25
25
  "typescript": "^6.0.2",
26
- "vite": "^8.0.5"
26
+ "vite": "^8.0.8"
27
27
  },
28
28
  "exports": {
29
29
  ".": {
@@ -96,5 +96,5 @@
96
96
  },
97
97
  "type": "module",
98
98
  "types": "./dist/types/htmlminifier.d.ts",
99
- "version": "6.1.2"
99
+ "version": "6.1.4"
100
100
  }
package/src/htmlparser.js CHANGED
@@ -32,9 +32,14 @@ const singleAttrValues = [
32
32
  /"([^"]*)"+/.source,
33
33
  // Attr value, single quotes
34
34
  /'([^']*)'+/.source,
35
- // Attr value, no quotes
35
+ // Attr value, no quotes (strict: excludes `=` per HTML spec)
36
36
  /([^ \t\n\f\r"'`=<>]+)/.source
37
37
  ];
38
+ // Lenient unquoted value pattern for `continueOnParseError`:
39
+ // allows `<`, `=`, and ``` per HTML error-recovery rules
40
+ // (all are parse errors in unquoted-attribute-value state but appended to the value)
41
+ // `"` and `'` remain excluded—permitting them requires broader test coverage
42
+ const singleAttrValueLenientUnquoted = /([^ \t\n\f\r"'>]+)/.source;
38
43
  // https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
39
44
  const qnameCapture = (function () {
40
45
  // https://www.npmjs.com/package/ncname
@@ -100,9 +105,11 @@ function stripDelimited(str, open, close) {
100
105
  }
101
106
 
102
107
  function buildAttrRegex(handler) {
108
+ const unquotedValue = handler.continueOnParseError ? singleAttrValueLenientUnquoted : singleAttrValues[2];
109
+ const attrValues = [singleAttrValues[0], singleAttrValues[1], unquotedValue];
103
110
  let pattern = singleAttrIdentifier.source +
104
111
  '(?:\\s*(' + joinSingleAttrAssigns(handler) + ')' +
105
- '[ \\t\\n\\f\\r]*(?:' + singleAttrValues.join('|') + '))?';
112
+ '[ \\t\\n\\f\\r]*(?:' + attrValues.join('|') + '))?';
106
113
  if (handler.customAttrSurround) {
107
114
  const attrClauses = [];
108
115
  for (let i = handler.customAttrSurround.length - 1; i >= 0; i--) {