https://github.com/nitin42/escaper
A small library which provides methods to escape and unescape HTML entities.
https://github.com/nitin42/escaper
Last synced: 3 months ago
JSON representation
A small library which provides methods to escape and unescape HTML entities.
- Host: GitHub
- URL: https://github.com/nitin42/escaper
- Owner: nitin42
- Created: 2016-09-07T15:33:54.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-15T16:16:32.000Z (over 8 years ago)
- Last Synced: 2025-02-15T06:04:48.177Z (4 months ago)
- Language: JavaScript
- Size: 28.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
HTML-Escaper
===================
[](https://travis-ci.org/nitin42/Escaper)

A small library which provides methods to `escape` and `unescape` HTML entities before inserting untrusted data into HTML element content. ([XSS](https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet) prevention)
## Installation
```
npm install -g es-en```
## Usage
``` javascriptvar hescape = require('es-en');
var escape = hescape.escape;
var unescape = hescape.unescape;var html = '
Help me!
';
var escaped = escape(html);
var unescaped = unescape(escaped);console.log('html', html, 'escaped', escaped, 'unescaped', unescaped);
htmlHelp me!
escaped <h1>Help me!</h1> unescapedHelp me!
```
## Tests
```
npm test
```
## Contributing
Add unit tests for any new or changed functionality.## License
MIT