Skip to content

wesleytodd/recursive-unescape

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Recursively UnEscape Objects/Arrays for HTML

Install:

$ npm install --save recursive-unescape

Recursivly unescapes strings in objects or arrays which were escaped for output in HTML. The most common use case for this is to process data that was passed from a server rendered app. See recursive-escape for use on the server when escaping the data.

Usage:

var unescape = require('recursive-unescape');

var obj = {
	"foo": "My unsafe <script>alert("You have been hacked!!");</script> string.",
	"number": 1,
	"arr": [
		"foo",
		"<h1>Hi!!</h1>"
	],
	"obj": {
		"nested": {
			"bar": "<"
		}
	}
};

var e = unescape(obj);

console.log(e.toJSON(e, '\t'));
/*
Output:

{
	foo: 'My unsafe <script>alert("You have been hacked!!");</script> string.',
	number: 1,
	arr: ['foo', '<h1>Hi!!</h1>'],
	obj: {
		nested: {
			bar: '<'
		}
	}
}
*/

About

Recursivly unescape objects and arrays

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published