summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/entities/lib/escape.js
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
committerRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
commit83354b2b88218090988dd6e526b0a2505b57e0f1 (patch)
treee3c73c38a122a78bb7e66fbb99056407edd9d4b9 /includes/external/addressbook/node_modules/entities/lib/escape.js
parent47b8f2299a483024c4a6a8876af825a010954caa (diff)
downloadpluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.gz
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.bz2
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.zip
Updated 5 files and added 1110 files (automated)
Diffstat (limited to 'includes/external/addressbook/node_modules/entities/lib/escape.js')
-rw-r--r--includes/external/addressbook/node_modules/entities/lib/escape.js112
1 files changed, 112 insertions, 0 deletions
diff --git a/includes/external/addressbook/node_modules/entities/lib/escape.js b/includes/external/addressbook/node_modules/entities/lib/escape.js
new file mode 100644
index 0000000..3716be5
--- /dev/null
+++ b/includes/external/addressbook/node_modules/entities/lib/escape.js
@@ -0,0 +1,112 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.escapeText = exports.escapeAttribute = exports.escapeUTF8 = exports.escape = exports.encodeXML = exports.getCodePoint = exports.xmlReplacer = void 0;
+exports.xmlReplacer = /["&'<>$\x80-\uFFFF]/g;
+var xmlCodeMap = new Map([
+ [34, "&quot;"],
+ [38, "&amp;"],
+ [39, "&apos;"],
+ [60, "&lt;"],
+ [62, "&gt;"],
+]);
+// For compatibility with node < 4, we wrap `codePointAt`
+exports.getCodePoint =
+// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+String.prototype.codePointAt != null
+ ? function (str, index) { return str.codePointAt(index); }
+ : // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ function (c, index) {
+ return (c.charCodeAt(index) & 0xfc00) === 0xd800
+ ? (c.charCodeAt(index) - 0xd800) * 0x400 +
+ c.charCodeAt(index + 1) -
+ 0xdc00 +
+ 0x10000
+ : c.charCodeAt(index);
+ };
+/**
+ * Encodes all non-ASCII characters, as well as characters not valid in XML
+ * documents using XML entities.
+ *
+ * If a character has no equivalent entity, a
+ * numeric hexadecimal reference (eg. `&#xfc;`) will be used.
+ */
+function encodeXML(str) {
+ var ret = "";
+ var lastIdx = 0;
+ var match;
+ while ((match = exports.xmlReplacer.exec(str)) !== null) {
+ var i = match.index;
+ var char = str.charCodeAt(i);
+ var next = xmlCodeMap.get(char);
+ if (next !== undefined) {
+ ret += str.substring(lastIdx, i) + next;
+ lastIdx = i + 1;
+ }
+ else {
+ ret += "".concat(str.substring(lastIdx, i), "&#x").concat((0, exports.getCodePoint)(str, i).toString(16), ";");
+ // Increase by 1 if we have a surrogate pair
+ lastIdx = exports.xmlReplacer.lastIndex += Number((char & 0xfc00) === 0xd800);
+ }
+ }
+ return ret + str.substr(lastIdx);
+}
+exports.encodeXML = encodeXML;
+/**
+ * Encodes all non-ASCII characters, as well as characters not valid in XML
+ * documents using numeric hexadecimal reference (eg. `&#xfc;`).
+ *
+ * Have a look at `escapeUTF8` if you want a more concise output at the expense
+ * of reduced transportability.
+ *
+ * @param data String to escape.
+ */
+exports.escape = encodeXML;
+function getEscaper(regex, map) {
+ return function escape(data) {
+ var match;
+ var lastIdx = 0;
+ var result = "";
+ while ((match = regex.exec(data))) {
+ if (lastIdx !== match.index) {
+ result += data.substring(lastIdx, match.index);
+ }
+ // We know that this chararcter will be in the map.
+ result += map.get(match[0].charCodeAt(0));
+ // Every match will be of length 1
+ lastIdx = match.index + 1;
+ }
+ return result + data.substring(lastIdx);
+ };
+}
+/**
+ * Encodes all characters not valid in XML documents using XML entities.
+ *
+ * Note that the output will be character-set dependent.
+ *
+ * @param data String to escape.
+ */
+exports.escapeUTF8 = getEscaper(/[&<>'"]/g, xmlCodeMap);
+/**
+ * Encodes all characters that have to be escaped in HTML attributes,
+ * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
+ *
+ * @param data String to escape.
+ */
+exports.escapeAttribute = getEscaper(/["&\u00A0]/g, new Map([
+ [34, "&quot;"],
+ [38, "&amp;"],
+ [160, "&nbsp;"],
+]));
+/**
+ * Encodes all characters that have to be escaped in HTML text,
+ * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
+ *
+ * @param data String to escape.
+ */
+exports.escapeText = getEscaper(/[&<>\u00A0]/g, new Map([
+ [38, "&amp;"],
+ [60, "&lt;"],
+ [62, "&gt;"],
+ [160, "&nbsp;"],
+]));
+//# sourceMappingURL=escape.js.map \ No newline at end of file