sanitize-html 2.13.0 → 2.14.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.
Files changed (2) hide show
  1. package/index.js +11 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -274,6 +274,15 @@ function sanitizeHtml(html, options, _recursing) {
274
274
  if (skip) {
275
275
  if (options.disallowedTagsMode === 'discard' || options.disallowedTagsMode === 'completelyDiscard') {
276
276
  // We want the contents but not this tag
277
+ if (frame.innerText && !hasText) {
278
+ const escaped = escapeHtml(frame.innerText);
279
+ if (options.textFilter) {
280
+ result += options.textFilter(escaped, name);
281
+ } else {
282
+ result += escapeHtml(frame.innerText);
283
+ }
284
+ addedText = true;
285
+ }
277
286
  return;
278
287
  }
279
288
  tempResult = result;
@@ -431,12 +440,13 @@ function sanitizeHtml(html, options, _recursing) {
431
440
  const allowedWildcardClasses = allowedClassesMap['*'];
432
441
  const allowedSpecificClassesGlob = allowedClassesGlobMap[name];
433
442
  const allowedSpecificClassesRegex = allowedClassesRegexMap[name];
443
+ const allowedWildcardClassesRegex = allowedClassesRegexMap['*'];
434
444
  const allowedWildcardClassesGlob = allowedClassesGlobMap['*'];
435
445
  const allowedClassesGlobs = [
436
446
  allowedSpecificClassesGlob,
437
447
  allowedWildcardClassesGlob
438
448
  ]
439
- .concat(allowedSpecificClassesRegex)
449
+ .concat(allowedSpecificClassesRegex, allowedWildcardClassesRegex)
440
450
  .filter(function (t) {
441
451
  return t;
442
452
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanitize-html",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "description": "Clean up user-submitted HTML, preserving allowlisted elements and allowlisted attributes on a per-element basis",
5
5
  "sideEffects": false,
6
6
  "main": "index.js",