init
This commit is contained in:
4
node_modules/htmlescape/.npmignore
generated
vendored
Normal file
4
node_modules/htmlescape/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/.gitignore
|
||||
/CHANGELOG.md
|
||||
/LICENSE
|
||||
/test
|
9
node_modules/htmlescape/CHANGELOG.md
generated
vendored
Normal file
9
node_modules/htmlescape/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
1.0.0 / 2014-09-29
|
||||
==================
|
||||
|
||||
* No more API changes
|
||||
|
||||
0.0.1 / 2014-09-28
|
||||
==================
|
||||
|
||||
* Initial release
|
9
node_modules/htmlescape/LICENSE
generated
vendored
Normal file
9
node_modules/htmlescape/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
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.
|
30
node_modules/htmlescape/README.md
generated
vendored
Normal file
30
node_modules/htmlescape/README.md
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# htmlescape
|
||||
|
||||
Properly escape JSON for usage as an object literal inside of a `<script>` tag. Use `htmlescape` in place of `JSON.stringify`. For more info see [JSON: The JavaScript subset that isn't](http://timelessrepo.com/json-isnt-a-javascript-subset).
|
||||
|
||||
## Transformations
|
||||
|
||||
| from | to |
|
||||
| -------- |:---------:|
|
||||
| `&` | `\\u0026` |
|
||||
| `>` | `\\u003e` |
|
||||
| `<` | `\\u003c` |
|
||||
| `\u2028` | `\\u2028` |
|
||||
| `\u2029` | `\\u2029` |
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var htmlescape = require('htmlescape');
|
||||
htmlescape({prop:'value'});
|
||||
//=> '{"prop":"value"}'
|
||||
```
|
||||
|
||||
Or in your templates:
|
||||
|
||||
```html
|
||||
<script>
|
||||
var payload = <%= htmlescape(payload) %>;
|
||||
</script>
|
||||
```
|
42
node_modules/htmlescape/htmlescape.js
generated
vendored
Normal file
42
node_modules/htmlescape/htmlescape.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Properly escape JSON for usage as an object literal inside of a `<script>` tag.
|
||||
* JS implementation of http://golang.org/pkg/encoding/json/#HTMLEscape
|
||||
* More info: http://timelessrepo.com/json-isnt-a-javascript-subset
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var ESCAPE_LOOKUP = {
|
||||
'&': '\\u0026',
|
||||
'>': '\\u003e',
|
||||
'<': '\\u003c',
|
||||
'\u2028': '\\u2028',
|
||||
'\u2029': '\\u2029'
|
||||
};
|
||||
|
||||
var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
|
||||
|
||||
function escaper(match) {
|
||||
return ESCAPE_LOOKUP[match];
|
||||
}
|
||||
|
||||
module.exports = function(obj) {
|
||||
return JSON.stringify(obj).replace(ESCAPE_REGEX, escaper);
|
||||
};
|
||||
|
||||
/***/
|
||||
|
||||
var TERMINATORS_LOOKUP = {
|
||||
'\u2028': '\\u2028',
|
||||
'\u2029': '\\u2029'
|
||||
};
|
||||
|
||||
var TERMINATORS_REGEX = /[\u2028\u2029]/g;
|
||||
|
||||
function sanitizer(match) {
|
||||
return TERMINATORS_LOOKUP[match];
|
||||
}
|
||||
|
||||
module.exports.sanitize = function(str) {
|
||||
return str.replace(TERMINATORS_REGEX, sanitizer);
|
||||
};
|
30
node_modules/htmlescape/package.json
generated
vendored
Normal file
30
node_modules/htmlescape/package.json
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "htmlescape",
|
||||
"version": "1.1.1",
|
||||
"description": "Properly escape JSON for usage as an object literal inside of a `<script>` tag",
|
||||
"keywords": [
|
||||
"escape",
|
||||
"encoding",
|
||||
"html",
|
||||
"json",
|
||||
"template"
|
||||
],
|
||||
"homepage": "https://github.com/zertosh/htmlescape",
|
||||
"license": "MIT",
|
||||
"author": "Andres Suarez <zertosh@gmail.com>",
|
||||
"main": "htmlescape.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/zertosh/htmlescape.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"tape": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user