pax_global_header 0000666 0000000 0000000 00000000064 12674376225 0014530 g ustar 00root root 0000000 0000000 52 comment=02dbcc367dd3069b73253ac08d87a40d37984239
htmlescape-1.1.1/ 0000775 0000000 0000000 00000000000 12674376225 0013655 5 ustar 00root root 0000000 0000000 htmlescape-1.1.1/.gitignore 0000664 0000000 0000000 00000000047 12674376225 0015646 0 ustar 00root root 0000000 0000000 .DS_Store
/npm-debug.log
/node_modules
htmlescape-1.1.1/.npmignore 0000664 0000000 0000000 00000000051 12674376225 0015650 0 ustar 00root root 0000000 0000000 /.gitignore
/CHANGELOG.md
/LICENSE
/test
htmlescape-1.1.1/CHANGELOG.md 0000664 0000000 0000000 00000000173 12674376225 0015467 0 ustar 00root root 0000000 0000000 1.0.0 / 2014-09-29
==================
* No more API changes
0.0.1 / 2014-09-28
==================
* Initial release
htmlescape-1.1.1/LICENSE 0000664 0000000 0000000 00000002070 12674376225 0014661 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2014 Andres Suarez
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
htmlescape-1.1.1/README.md 0000664 0000000 0000000 00000001227 12674376225 0015136 0 ustar 00root root 0000000 0000000 # htmlescape
Properly escape JSON for usage as an object literal inside of a `
```
htmlescape-1.1.1/htmlescape.js 0000664 0000000 0000000 00000001537 12674376225 0016346 0 ustar 00root root 0000000 0000000 /**
* Properly escape JSON for usage as an object literal inside of a `'};
t.equal(htmlescape(evilObj), '{"evil":"\\u003cscript\\u003e\\u003c/script\\u003e"}');
t.end();
});
t.test('with angle brackets should parse back', function(t) {
var evilObj = {evil: ''};
t.looseEqual(JSON.parse(htmlescape(evilObj)), evilObj);
t.end();
});
t.test('with ampersands should escape', function(t) {
var evilObj = {evil: '&'};
t.equal(htmlescape(evilObj), '{"evil":"\\u0026"}');
t.end();
});
t.test('with ampersands should parse back', function(t) {
var evilObj = {evil: '&'};
t.looseEqual(JSON.parse(htmlescape(evilObj)), evilObj);
t.end();
});
t.test('with "LINE SEPARATOR" and "PARAGRAPH SEPARATOR" should escape', function(t) {
var evilObj = {evil: '\u2028\u2029'};
t.equal(htmlescape(evilObj), '{"evil":"\\u2028\\u2029"}');
t.end();
});
t.test('with "LINE SEPARATOR" and "PARAGRAPH SEPARATOR" should parse back', function(t) {
var evilObj = {evil: '\u2028\u2029'};
t.looseEqual(JSON.parse(htmlescape(evilObj)), evilObj);
t.end();
});
t.test('escaped line terminators should work', function(t) {
t.doesNotThrow(function() {
vm.runInNewContext('(' + htmlescape({evil: '\u2028\u2029'}) + ')');
});
t.end();
});
t.test('unescaped line terminators should not work', function(t) {
t.throws(function() {
vm.runInNewContext('(' + JSON.stringify({evil: '\u2028\u2029'}) + ')');
});
t.end();
});
t.test('sanitized terminators should work', function(t) {
t.doesNotThrow(function() {
vm.runInNewContext(htmlescape.sanitize('("\u2028\u2029")'));
});
t.end();
});
t.test('unsanitized terminators should not work', function(t) {
t.throws(function() {
vm.runInNewContext('("\u2028\u2029")');
});
t.end();
});
});