diff options
Diffstat (limited to 'src/node_modules/js-string-escape')
-rw-r--r-- | src/node_modules/js-string-escape/CHANGELOG.md | 13 | ||||
-rw-r--r-- | src/node_modules/js-string-escape/LICENSE | 21 | ||||
-rw-r--r-- | src/node_modules/js-string-escape/README.md | 44 | ||||
-rw-r--r-- | src/node_modules/js-string-escape/index.js | 22 | ||||
-rw-r--r-- | src/node_modules/js-string-escape/package.json | 38 |
5 files changed, 138 insertions, 0 deletions
diff --git a/src/node_modules/js-string-escape/CHANGELOG.md b/src/node_modules/js-string-escape/CHANGELOG.md new file mode 100644 index 0000000..4318bf9 --- /dev/null +++ b/src/node_modules/js-string-escape/CHANGELOG.md @@ -0,0 +1,13 @@ +# master + +# 1.0.1 + +* Exclude unused files from npm distribution + +# 1.0.0 + +* No change; version bumped to indicate that this package is considered stable + +# 0.0.1 + +* Initial release diff --git a/src/node_modules/js-string-escape/LICENSE b/src/node_modules/js-string-escape/LICENSE new file mode 100644 index 0000000..4ce0499 --- /dev/null +++ b/src/node_modules/js-string-escape/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013 Jo Liss + +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. diff --git a/src/node_modules/js-string-escape/README.md b/src/node_modules/js-string-escape/README.md new file mode 100644 index 0000000..3147c1b --- /dev/null +++ b/src/node_modules/js-string-escape/README.md @@ -0,0 +1,44 @@ +# js-string-escape + +[![Build Status](https://travis-ci.org/joliss/js-string-escape.png?branch=master)](https://travis-ci.org/joliss/js-string-escape) + +Escape any string to be a valid JavaScript string literal between double +quotes or single quotes. + +## Installation + +``` +npm install js-string-escape +``` + +## Example + +If you need to generate JavaScript output, this library will help you safely +put arbitrary data in JavaScript strings: + +```js +jsStringEscape = require('js-string-escape') + +console.log('"' + jsStringEscape('Quotes (\", \'), newlines (\n), etc.') + '"') +// => "Quotes (\", \'), newlines (\n), etc." +``` + +In other words, given any string `s`, the following invariants hold: + +```js +eval('"' + jsStringEscape(s) + '"') === s +eval("'" + jsStringEscape(s) + "'") === s +``` + +These `eval` expressions are safe with untrusted strings `s`. + +Non-strings will be cast to strings. + +## Compliance + +This library has been checked against [ECMAScript +5.1](http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4) and tested +against all Unicode code points. + +Note that the returned string is not necessarily valid JSON, since JSON +disallows control characters, and `\'` is illegal in JSON. diff --git a/src/node_modules/js-string-escape/index.js b/src/node_modules/js-string-escape/index.js new file mode 100644 index 0000000..256fdf4 --- /dev/null +++ b/src/node_modules/js-string-escape/index.js @@ -0,0 +1,22 @@ +module.exports = function (string) { + return ('' + string).replace(/["'\\\n\r\u2028\u2029]/g, function (character) { + // Escape all characters not included in SingleStringCharacters and + // DoubleStringCharacters on + // http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4 + switch (character) { + case '"': + case "'": + case '\\': + return '\\' + character + // Four possible LineTerminator characters need to be escaped: + case '\n': + return '\\n' + case '\r': + return '\\r' + case '\u2028': + return '\\u2028' + case '\u2029': + return '\\u2029' + } + }) +} diff --git a/src/node_modules/js-string-escape/package.json b/src/node_modules/js-string-escape/package.json new file mode 100644 index 0000000..fc2be31 --- /dev/null +++ b/src/node_modules/js-string-escape/package.json @@ -0,0 +1,38 @@ +{ + "name": "js-string-escape", + "version": "1.0.1", + "description": "Escape strings for use as JavaScript string literals", + "main": "index.js", + "scripts": { + "test": "tap test" + }, + "repository": { + "type": "git", + "url": "https://github.com/joliss/js-string-escape" + }, + "keywords": [ + "string", + "escape", + "backslash", + "javascript", + "ecmascript" + ], + "author": "Jo Liss <joliss42@gmail.com>", + "contributors": [ + { + "name": "Mathias Bynens", + "url": "http://mathiasbynens.be/" + } + ], + "license": "MIT", + "devDependencies" : { + "tap": "~> 0.4.2", + "punycode": "~> 1.2.1" + }, + "engines": { + "node": ">= 0.8" + }, + "files": [ + "index.js" + ] +} |