JSPM

html-escape

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8470
  • Score
    100M100P100Q130655F
  • License Public Domain

Escape string for use in html

Package Exports

  • html-escape

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (html-escape) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

html-escape

Escape a string to be safe for use in html. &, <, ', and " characters are replaced with with their named character references: &amp;, &lt;, &apos;, and &quot;. Escaped strings will be safe for use in the following contexts:

Example

var escape = require("html-escape");
var xssAttempt = "Hello <script>while(1);</script> world!";
// Output safe html
console.log("<p>" + escape(xssAttempt) + "</p>");
// "<p>Hello &lt;script>while(1);&lt;/script> world!</p>"

Installation

npm install html-escape