How to use the sanitize-html.default function in sanitize-html

To help you get started, we’ve selected a few sanitize-html examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nylas-mail-lives / nylas-mail / packages / client-app / src / services / sanitize-transformer.es6 View on Github external
run(body, settings = Preset.Strict) {
    if (settings.allowedAttributes instanceof Array) {
      const attrMap = {};
      for (const tag of settings.allowedTags) {
        attrMap[tag] = settings.allowedAttributes;
      }
      settings.allowedAttributes = attrMap;
    }

    if (!sanitizeHtml) {
      sanitizeHtml = require('sanitize-html').default; //eslint-disable-line
    }
    return Promise.resolve(sanitizeHtml(body, settings));
  }
}

sanitize-html

Clean up user-submitted HTML, preserving allowlisted elements and allowlisted attributes on a per-element basis

MIT
Latest version published 1 month ago

Package Health Score

94 / 100
Full package analysis