An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

        

HTML-Escaper
===================
[![Build Status](https://travis-ci.org/nitin42/Escaper.svg?branch=master)](https://travis-ci.org/nitin42/Escaper)
![Dependencies](https://david-dm.org/nitin42/Escaper.svg)
![npm-version](https://img.shields.io/badge/npm-0.1.6-green.svg)

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

``` javascript

var 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);

html

Help me!

escaped <h1>Help me!</h1> unescaped

Help me!

```

## Tests
```
npm test
```
## Contributing

Add unit tests for any new or changed functionality.

## License

MIT