aboutsummaryrefslogtreecommitdiff
path: root/node_modules/html-escaper
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
committerJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
commit5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch)
tree360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/html-escaper
parentb500a50f1b97d93c98b36ed9a980f8188d648147 (diff)
downloadLYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz
LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/html-escaper')
-rw-r--r--node_modules/html-escaper/LICENSE.txt19
-rw-r--r--node_modules/html-escaper/README.md97
-rw-r--r--node_modules/html-escaper/cjs/index.js65
-rw-r--r--node_modules/html-escaper/cjs/package.json1
-rw-r--r--node_modules/html-escaper/esm/index.js62
-rw-r--r--node_modules/html-escaper/index.js70
-rw-r--r--node_modules/html-escaper/min.js1
-rw-r--r--node_modules/html-escaper/package.json42
-rw-r--r--node_modules/html-escaper/test/index.js23
-rw-r--r--node_modules/html-escaper/test/package.json1
10 files changed, 381 insertions, 0 deletions
diff --git a/node_modules/html-escaper/LICENSE.txt b/node_modules/html-escaper/LICENSE.txt
new file mode 100644
index 0000000..dcfa0ae
--- /dev/null
+++ b/node_modules/html-escaper/LICENSE.txt
@@ -0,0 +1,19 @@
+Copyright (C) 2017-present by Andrea Giammarchi - @WebReflection
+
+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/node_modules/html-escaper/README.md b/node_modules/html-escaper/README.md
new file mode 100644
index 0000000..3dca341
--- /dev/null
+++ b/node_modules/html-escaper/README.md
@@ -0,0 +1,97 @@
+# html-escaper [![Build Status](https://travis-ci.org/WebReflection/html-escaper.svg?branch=master)](https://travis-ci.org/WebReflection/html-escaper) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/html-escaper/badge.svg?branch=master)](https://coveralls.io/github/WebReflection/html-escaper?branch=master)
+A simple module to escape/unescape common problematic entities.
+
+
+### How
+This package is available in npm so `npm install html-escaper` is all you need to do, using eventually the global flag too.
+
+Once the module is present
+```js
+var html = require('html-escaper');
+
+// two basic methods
+html.escape('string');
+html.unescape('escaped string');
+```
+
+
+### Why
+there is basically one rule only: do not **ever** replace one char after another if you are transforming a string into another.
+
+```js
+// WARNING: THIS IS WRONG
+// if you are that kind of dev that does this
+function escape(s) {
+ return s.replace(/&/g, "&amp;")
+ .replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;")
+ .replace(/'/g, "&#39;")
+ .replace(/"/g, "&quot;");
+}
+
+// you might be the same dev that does this too
+function unescape(s) {
+ return s.replace(/&amp;/g, "&")
+ .replace(/&lt;/g, "<")
+ .replace(/&gt;/g, ">")
+ .replace(/&#39;/g, "'")
+ .replace(/&quot;/g, '"');
+}
+
+// guess what we have here ?
+unescape('&amp;lt;');
+
+// now guess this XSS too ...
+unescape('&amp;lt;script&amp;gt;alert("yo")&amp;lt;/script&amp;gt;');
+
+
+```
+
+The last example will produce `<script>alert("yo")</script>` instead of the expected `&lt;script&gt;alert("yo")&lt;/script&gt;`.
+
+Nothing like this could possibly happen if we grab all chars at once and either ways.
+It's just a fortunate case that after swapping `&` with `&amp;` no other replace will be affected, but it's not portable and universally a bad practice.
+
+Grab all chars at once, no excuses!
+
+
+
+**more details**
+As somebody might think it's an `unescape` issue only, it's not. Being an anti-pattern with side effects works both ways.
+
+As example, changing the order of the replacement in escaping would produce the unexpected:
+```js
+function escape(s) {
+ return s.replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;")
+ .replace(/'/g, "&#39;")
+ .replace(/"/g, "&quot;")
+ .replace(/&/g, "&amp;");
+}
+
+escape('<'); // &amp;lt; instead of &lt;
+```
+If we do not want to code with the fear that the order wasn't perfect or that our order in either escaping or unescaping is different from the order another method or function used, if we understand the issue and we agree it's potentially a disaster prone approach, if we add the fact in this case creating 4 RegExp objects each time and invoking 4 times `.replace` trough the `String.prototype` is also potentially slower than creating one function only holding one object, or holding the function too, we should agree there is not absolutely any valid reason to keep proposing a char-by-char implementation.
+
+We have proofs this approach can fail already so ... why should we risk? Just avoid and grab all chars at once or simply use this tiny utility.
+
+### Backtick
+Internt explorer < 9 has [some backtick issue](https://html5sec.org/#102)
+
+For compatibility sake with common server-side HTML entities encoders and decoders, and in order to have the most reliable I/O, this little utility will NOT fix this IE < 9 problem.
+
+It is also important to note that if we create valid HTML and we set attributes at runtime through this utility, backticks in strings cannot possibly affect attribute behaviors.
+
+```js
+var img = new Image();
+img.src = html.escape(
+ 'x` `<script>alert(1)</script>"` `'
+);
+// it won't cause problems even in IE < 9
+```
+
+**However**, if you use `innerHTML` and you target IE < 9 then [this **might** be a problem](https://github.com/nette/nette/issues/1496).
+
+Accordingly, if you need more chars and/or backticks to be escaped and unescaped, feel free to use alternatives like [lodash](https://github.com/lodash/lodash) or [he](https://www.npmjs.com/package/he)
+
+Here a bit more of [my POV](https://github.com/WebReflection/html-escaper/commit/52d554fc6e8583b6ffdd357967cf71962fc07cf6#commitcomment-10625122) and why I haven't implemented same thing alternatives did. Good news: those are alternatives ;-) \ No newline at end of file
diff --git a/node_modules/html-escaper/cjs/index.js b/node_modules/html-escaper/cjs/index.js
new file mode 100644
index 0000000..164a34c
--- /dev/null
+++ b/node_modules/html-escaper/cjs/index.js
@@ -0,0 +1,65 @@
+'use strict';
+/**
+ * Copyright (C) 2017-present by Andrea Giammarchi - @WebReflection
+ *
+ * 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.
+ */
+
+var replace = ''.replace;
+
+var ca = /[&<>'"]/g;
+var es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
+
+var esca = {
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ "'": '&#39;',
+ '"': '&quot;'
+};
+var unes = {
+ '&amp;': '&',
+ '&#38;': '&',
+ '&lt;': '<',
+ '&#60;': '<',
+ '&gt;': '>',
+ '&#62;': '>',
+ '&apos;': "'",
+ '&#39;': "'",
+ '&quot;': '"',
+ '&#34;': '"'
+};
+
+function escape(es) {
+ return replace.call(es, ca, pe);
+}
+exports.escape = escape;
+
+function unescape(un) {
+ return replace.call(un, es, cape);
+}
+exports.unescape = unescape;
+
+function pe(m) {
+ return esca[m];
+}
+
+function cape(m) {
+ return unes[m];
+}
diff --git a/node_modules/html-escaper/cjs/package.json b/node_modules/html-escaper/cjs/package.json
new file mode 100644
index 0000000..0292b99
--- /dev/null
+++ b/node_modules/html-escaper/cjs/package.json
@@ -0,0 +1 @@
+{"type":"commonjs"} \ No newline at end of file
diff --git a/node_modules/html-escaper/esm/index.js b/node_modules/html-escaper/esm/index.js
new file mode 100644
index 0000000..e05b93f
--- /dev/null
+++ b/node_modules/html-escaper/esm/index.js
@@ -0,0 +1,62 @@
+/**
+ * Copyright (C) 2017-present by Andrea Giammarchi - @WebReflection
+ *
+ * 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.
+ */
+
+var replace = ''.replace;
+
+var ca = /[&<>'"]/g;
+var es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
+
+var esca = {
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ "'": '&#39;',
+ '"': '&quot;'
+};
+var unes = {
+ '&amp;': '&',
+ '&#38;': '&',
+ '&lt;': '<',
+ '&#60;': '<',
+ '&gt;': '>',
+ '&#62;': '>',
+ '&apos;': "'",
+ '&#39;': "'",
+ '&quot;': '"',
+ '&#34;': '"'
+};
+
+export function escape(es) {
+ return replace.call(es, ca, pe);
+};
+
+export function unescape(un) {
+ return replace.call(un, es, cape);
+};
+
+function pe(m) {
+ return esca[m];
+}
+
+function cape(m) {
+ return unes[m];
+}
diff --git a/node_modules/html-escaper/index.js b/node_modules/html-escaper/index.js
new file mode 100644
index 0000000..6c3f2ab
--- /dev/null
+++ b/node_modules/html-escaper/index.js
@@ -0,0 +1,70 @@
+var html = (function (exports) {
+ 'use strict';
+
+ /**
+ * Copyright (C) 2017-present by Andrea Giammarchi - @WebReflection
+ *
+ * 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.
+ */
+
+ var replace = ''.replace;
+
+ var ca = /[&<>'"]/g;
+ var es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
+
+ var esca = {
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ "'": '&#39;',
+ '"': '&quot;'
+ };
+ var unes = {
+ '&amp;': '&',
+ '&#38;': '&',
+ '&lt;': '<',
+ '&#60;': '<',
+ '&gt;': '>',
+ '&#62;': '>',
+ '&apos;': "'",
+ '&#39;': "'",
+ '&quot;': '"',
+ '&#34;': '"'
+ };
+
+ function escape(es) {
+ return replace.call(es, ca, pe);
+ }
+ function unescape(un) {
+ return replace.call(un, es, cape);
+ }
+ function pe(m) {
+ return esca[m];
+ }
+
+ function cape(m) {
+ return unes[m];
+ }
+
+ exports.escape = escape;
+ exports.unescape = unescape;
+
+ return exports;
+
+}({}));
diff --git a/node_modules/html-escaper/min.js b/node_modules/html-escaper/min.js
new file mode 100644
index 0000000..54d0c23
--- /dev/null
+++ b/node_modules/html-escaper/min.js
@@ -0,0 +1 @@
+var html=function(t){"use strict";var n="".replace,u=/[&<>'"]/g,r=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g,a={"&":"&amp;","<":"&lt;",">":"&gt;","'":"&#39;",'"':"&quot;"},e={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"'};function c(t){return a[t]}function o(t){return e[t]}return t.escape=function(t){return n.call(t,u,c)},t.unescape=function(t){return n.call(t,r,o)},t}({}); \ No newline at end of file
diff --git a/node_modules/html-escaper/package.json b/node_modules/html-escaper/package.json
new file mode 100644
index 0000000..81d06a9
--- /dev/null
+++ b/node_modules/html-escaper/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "html-escaper",
+ "version": "2.0.2",
+ "description": "fast and safe way to escape and unescape &<>'\" chars",
+ "main": "./cjs/index.js",
+ "unpkg": "min.js",
+ "scripts": {
+ "build": "npm run cjs && npm run rollup && npm run minify && npm test && npm run size",
+ "cjs": "ascjs esm cjs",
+ "coveralls": "cat ./coverage/lcov.info | coveralls",
+ "minify": "uglifyjs index.js --comments=/^!/ --compress --mangle -o min.js",
+ "rollup": "rollup --config rollup.config.js",
+ "size": "cat index.js | wc -c;cat min.js | wc -c;gzip -c min.js | wc -c",
+ "test": "istanbul cover ./test/index.js"
+ },
+ "module": "./esm/index.js",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/WebReflection/html-escaper.git"
+ },
+ "keywords": [
+ "html",
+ "escape",
+ "encode",
+ "unescape",
+ "decode",
+ "entities"
+ ],
+ "author": "Andrea Giammarchi",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/WebReflection/html-escaper/issues"
+ },
+ "homepage": "https://github.com/WebReflection/html-escaper",
+ "devDependencies": {
+ "ascjs": "^3.1.2",
+ "coveralls": "^3.0.11",
+ "istanbul": "^0.4.5",
+ "rollup": "^2.1.0",
+ "uglify-js": "^3.8.0"
+ }
+}
diff --git a/node_modules/html-escaper/test/index.js b/node_modules/html-escaper/test/index.js
new file mode 100644
index 0000000..0eb00de
--- /dev/null
+++ b/node_modules/html-escaper/test/index.js
@@ -0,0 +1,23 @@
+delete Object.freeze;
+
+var html = require('../cjs');
+
+console.assert(
+ html.escape('&<>\'"') === '&amp;&lt;&gt;&#39;&quot;',
+ 'correct escape'
+);
+
+console.assert(
+ html.escape('<>\'"&') === '&lt;&gt;&#39;&quot;&amp;',
+ 'correct inverted escape'
+);
+
+console.assert(
+ '&<>\'"' === html.unescape('&amp;&lt;&gt;&#39;&quot;'),
+ 'correct unescape'
+);
+
+console.assert(
+ '<>\'"&' === html.unescape('&lt;&gt;&#39;&quot;&amp;'),
+ 'correct inverted unescape'
+);
diff --git a/node_modules/html-escaper/test/package.json b/node_modules/html-escaper/test/package.json
new file mode 100644
index 0000000..0292b99
--- /dev/null
+++ b/node_modules/html-escaper/test/package.json
@@ -0,0 +1 @@
+{"type":"commonjs"} \ No newline at end of file