@webex/helper-html 3.0.0-bnr.4 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js ADDED
@@ -0,0 +1,6 @@
1
+ const config = {
2
+ root: true,
3
+ extends: ['@webex/eslint-config-legacy'],
4
+ };
5
+
6
+ module.exports = config;
@@ -0,0 +1,3 @@
1
+ const babelConfigLegacy = require('@webex/babel-config-legacy');
2
+
3
+ module.exports = babelConfigLegacy;
@@ -1 +1 @@
1
- {"version":3,"names":["escapeMe","escape","html","resolve","escapeSync","replace","entityReplacer","char"],"sources":["html-base.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nconst escapeMe = /(<|>|&)/g;\n\n// escape and escapeSync probably don't both need to exist, but it seemed like a\n// good idea in case we ever want to for the future.\n\n/**\n * Escapes HTML\n * @param {[type]} html\n * @returns {[type]}\n */\nexport function escape(html) {\n return new Promise((resolve) => resolve(escapeSync(html)));\n}\n\n/**\n * Synchronously escape HTML\n * @param {[type]} html\n * @returns {[type]}\n */\nexport function escapeSync(html) {\n return html.replace(escapeMe, entityReplacer);\n}\n\n/**\n * @param {string} char\n * @private\n * @returns {string}\n */\nfunction entityReplacer(char) {\n switch (char) {\n case '<':\n return '&lt;';\n case '>':\n return '&gt;';\n case '&':\n return '&amp;';\n default:\n return char;\n }\n}\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;;AAEA,IAAMA,QAAQ,GAAG,UAAU;;AAE3B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,MAAM,CAACC,IAAI,EAAE;EAC3B,OAAO,qBAAY,UAACC,OAAO;IAAA,OAAKA,OAAO,CAACC,UAAU,CAACF,IAAI,CAAC,CAAC;EAAA,EAAC;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASE,UAAU,CAACF,IAAI,EAAE;EAC/B,OAAOA,IAAI,CAACG,OAAO,CAACL,QAAQ,EAAEM,cAAc,CAAC;AAC/C;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAc,CAACC,IAAI,EAAE;EAC5B,QAAQA,IAAI;IACV,KAAK,GAAG;MACN,OAAO,MAAM;IACf,KAAK,GAAG;MACN,OAAO,MAAM;IACf,KAAK,GAAG;MACN,OAAO,OAAO;IAChB;MACE,OAAOA,IAAI;EAAC;AAElB"}
1
+ {"version":3,"names":["escapeMe","escape","html","_promise","default","resolve","escapeSync","replace","entityReplacer","char"],"sources":["html-base.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nconst escapeMe = /(<|>|&)/g;\n\n// escape and escapeSync probably don't both need to exist, but it seemed like a\n// good idea in case we ever want to for the future.\n\n/**\n * Escapes HTML\n * @param {[type]} html\n * @returns {[type]}\n */\nexport function escape(html) {\n return new Promise((resolve) => resolve(escapeSync(html)));\n}\n\n/**\n * Synchronously escape HTML\n * @param {[type]} html\n * @returns {[type]}\n */\nexport function escapeSync(html) {\n return html.replace(escapeMe, entityReplacer);\n}\n\n/**\n * @param {string} char\n * @private\n * @returns {string}\n */\nfunction entityReplacer(char) {\n switch (char) {\n case '<':\n return '&lt;';\n case '>':\n return '&gt;';\n case '&':\n return '&amp;';\n default:\n return char;\n }\n}\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;;AAEA,IAAMA,QAAQ,GAAG,UAAU;;AAE3B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,MAAMA,CAACC,IAAI,EAAE;EAC3B,OAAO,IAAAC,QAAA,CAAAC,OAAA,CAAY,UAACC,OAAO;IAAA,OAAKA,OAAO,CAACC,UAAU,CAACJ,IAAI,CAAC,CAAC;EAAA,EAAC;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASI,UAAUA,CAACJ,IAAI,EAAE;EAC/B,OAAOA,IAAI,CAACK,OAAO,CAACP,QAAQ,EAAEQ,cAAc,CAAC;AAC/C;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAcA,CAACC,IAAI,EAAE;EAC5B,QAAQA,IAAI;IACV,KAAK,GAAG;MACN,OAAO,MAAM;IACf,KAAK,GAAG;MACN,OAAO,MAAM;IACf,KAAK,GAAG;MACN,OAAO,OAAO;IAChB;MACE,OAAOA,IAAI;EACf;AACF"}
package/dist/html.js CHANGED
@@ -19,8 +19,12 @@ _Object$defineProperty(exports, "escapeSync", {
19
19
  });
20
20
  exports.filterSync = exports.filterEscapeSync = exports.filterEscape = exports.filter = void 0;
21
21
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
22
- var _curry2 = _interopRequireDefault(require("lodash/curry"));
22
+ var _lodash = require("lodash");
23
23
  var _htmlBase = require("./html-base");
24
+ /*!
25
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
26
+ */
27
+
24
28
  /**
25
29
  * @param {Object} allowedTags
26
30
  * @param {Array<string>} allowedStyles
@@ -49,12 +53,8 @@ function noop() {
49
53
  function noopSync(processCallback, allowedTags, allowedStyles, html) {
50
54
  return html;
51
55
  }
52
- var filter = (0, _curry2.default)(noop, 4);
53
- exports.filter = filter;
54
- var filterSync = (0, _curry2.default)(noopSync, 4);
55
- exports.filterSync = filterSync;
56
- var filterEscape = (0, _curry2.default)(noop, 4);
57
- exports.filterEscape = filterEscape;
58
- var filterEscapeSync = (0, _curry2.default)(noopSync, 4);
59
- exports.filterEscapeSync = filterEscapeSync;
56
+ var filter = exports.filter = (0, _lodash.curry)(noop, 4);
57
+ var filterSync = exports.filterSync = (0, _lodash.curry)(noopSync, 4);
58
+ var filterEscape = exports.filterEscape = (0, _lodash.curry)(noop, 4);
59
+ var filterEscapeSync = exports.filterEscapeSync = (0, _lodash.curry)(noopSync, 4);
60
60
  //# sourceMappingURL=html.js.map
package/dist/html.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["noop","args","resolve","noopSync","processCallback","allowedTags","allowedStyles","html","filter","filterSync","filterEscape","filterEscapeSync"],"sources":["html.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {curry} from 'lodash';\n\nexport {escape, escapeSync} from './html-base';\n\n/**\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @private\n * @returns {string}\n */\nfunction noop(...args) {\n return new Promise((resolve) => {\n resolve(noopSync(...args));\n });\n}\n\n/**\n * @param {function} processCallback callback function to do additional\n * processing on node. of the form process(node)\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @private\n * @returns {string}\n */\nfunction noopSync(processCallback, allowedTags, allowedStyles, html) {\n return html;\n}\n\nexport const filter = curry(noop, 4);\nexport const filterSync = curry(noopSync, 4);\nexport const filterEscape = curry(noop, 4);\nexport const filterEscapeSync = curry(noopSync, 4);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAMA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,IAAI,GAAU;EAAA,kCAANC,IAAI;IAAJA,IAAI;EAAA;EACnB,OAAO,qBAAY,UAACC,OAAO,EAAK;IAC9BA,OAAO,CAACC,QAAQ,eAAIF,IAAI,CAAC,CAAC;EAC5B,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,QAAQ,CAACC,eAAe,EAAEC,WAAW,EAAEC,aAAa,EAAEC,IAAI,EAAE;EACnE,OAAOA,IAAI;AACb;AAEO,IAAMC,MAAM,GAAG,qBAAMR,IAAI,EAAE,CAAC,CAAC;AAAC;AAC9B,IAAMS,UAAU,GAAG,qBAAMN,QAAQ,EAAE,CAAC,CAAC;AAAC;AACtC,IAAMO,YAAY,GAAG,qBAAMV,IAAI,EAAE,CAAC,CAAC;AAAC;AACpC,IAAMW,gBAAgB,GAAG,qBAAMR,QAAQ,EAAE,CAAC,CAAC;AAAC"}
1
+ {"version":3,"names":["_lodash","require","_htmlBase","noop","_len","arguments","length","args","Array","_key","_promise","default","resolve","noopSync","apply","processCallback","allowedTags","allowedStyles","html","filter","exports","curry","filterSync","filterEscape","filterEscapeSync"],"sources":["html.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {curry} from 'lodash';\n\nexport {escape, escapeSync} from './html-base';\n\n/**\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @private\n * @returns {string}\n */\nfunction noop(...args) {\n return new Promise((resolve) => {\n resolve(noopSync(...args));\n });\n}\n\n/**\n * @param {function} processCallback callback function to do additional\n * processing on node. of the form process(node)\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @private\n * @returns {string}\n */\nfunction noopSync(processCallback, allowedTags, allowedStyles, html) {\n return html;\n}\n\nexport const filter = curry(noop, 4);\nexport const filterSync = curry(noopSync, 4);\nexport const filterEscape = curry(noop, 4);\nexport const filterEscapeSync = curry(noopSync, 4);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AANA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,IAAIA,CAAA,EAAU;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAANC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EACnB,OAAO,IAAAC,QAAA,CAAAC,OAAA,CAAY,UAACC,OAAO,EAAK;IAC9BA,OAAO,CAACC,QAAQ,CAAAC,KAAA,SAAIP,IAAI,CAAC,CAAC;EAC5B,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASM,QAAQA,CAACE,eAAe,EAAEC,WAAW,EAAEC,aAAa,EAAEC,IAAI,EAAE;EACnE,OAAOA,IAAI;AACb;AAEO,IAAMC,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG,IAAAE,aAAK,EAAClB,IAAI,EAAE,CAAC,CAAC;AAC7B,IAAMmB,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAG,IAAAD,aAAK,EAACR,QAAQ,EAAE,CAAC,CAAC;AACrC,IAAMU,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,IAAAF,aAAK,EAAClB,IAAI,EAAE,CAAC,CAAC;AACnC,IAAMqB,gBAAgB,GAAAJ,OAAA,CAAAI,gBAAA,GAAG,IAAAH,aAAK,EAACR,QAAQ,EAAE,CAAC,CAAC"}
package/dist/html.shim.js CHANGED
@@ -20,11 +20,14 @@ _Object$defineProperty(exports, "escapeSync", {
20
20
  exports.filterSync = exports.filterEscapeSync = exports.filterEscape = exports.filter = void 0;
21
21
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
22
22
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
23
- var _reduce2 = _interopRequireDefault(require("lodash/reduce"));
24
- var _includes2 = _interopRequireDefault(require("lodash/includes"));
25
- var _forEach2 = _interopRequireDefault(require("lodash/forEach"));
26
- var _curry2 = _interopRequireDefault(require("lodash/curry"));
23
+ var _lodash = require("lodash");
27
24
  var _htmlBase = require("./html-base");
25
+ /*!
26
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
27
+ */
28
+
29
+ /* eslint-env browser */
30
+
28
31
  /**
29
32
  * Some browsers don't implement {@link Element#remove()} or
30
33
  * {@link NodeList#remove()} or {@link HTMLCollection#remove()}. This wrapper
@@ -74,7 +77,7 @@ function _filter() {
74
77
  * @param {string} html html to filter
75
78
  * @returns {string}
76
79
  */
77
- var filter = (0, _curry2.default)(_filter, 4);
80
+ var filter = exports.filter = (0, _lodash.curry)(_filter, 4);
78
81
 
79
82
  /**
80
83
  * @param {function} processCallback callback function to do additional
@@ -85,7 +88,6 @@ var filter = (0, _curry2.default)(_filter, 4);
85
88
  * @private
86
89
  * @returns {string}
87
90
  */
88
- exports.filter = filter;
89
91
  function _filterSync(processCallback, allowedTags, allowedStyles, html) {
90
92
  if (!html || !allowedStyles || !allowedTags) {
91
93
  if (html.length === 0) {
@@ -113,10 +115,10 @@ function _filterSync(processCallback, allowedTags, allowedStyles, html) {
113
115
  var nodeName = node.nodeName.toLowerCase();
114
116
  var allowedTagNames = (0, _keys.default)(allowedTags);
115
117
  depthFirstForEach(node.childNodes, filterNode);
116
- if ((0, _includes2.default)(allowedTagNames, nodeName)) {
118
+ if ((0, _lodash.includes)(allowedTagNames, nodeName)) {
117
119
  var allowedAttributes = allowedTags[nodeName];
118
- (0, _forEach2.default)(listAttributeNames(node.attributes), function (attrName) {
119
- if (!(0, _includes2.default)(allowedAttributes, attrName)) {
120
+ (0, _lodash.forEach)(listAttributeNames(node.attributes), function (attrName) {
121
+ if (!(0, _lodash.includes)(allowedAttributes, attrName)) {
120
122
  node.removeAttribute(attrName);
121
123
  } else if (attrName === 'href' || attrName === 'src') {
122
124
  var attrValue = node.attributes.getNamedItem(attrName).value.trim().toLowerCase();
@@ -130,7 +132,7 @@ function _filterSync(processCallback, allowedTags, allowedStyles, html) {
130
132
  } else if (attrName === 'style') {
131
133
  var styles = node.attributes.getNamedItem('style').value.split(';').map(function (style) {
132
134
  var styleName = trim(style.split(':')[0]);
133
- if ((0, _includes2.default)(allowedStyles, styleName)) {
135
+ if ((0, _lodash.includes)(allowedStyles, styleName)) {
134
136
  return style;
135
137
  }
136
138
  return null;
@@ -198,10 +200,10 @@ function _filterEscapeSync(processCallback, allowedTags, allowedStyles, html) {
198
200
  depthFirstForEach(node.childNodes, filterNode);
199
201
  var nodeName = node.nodeName.toLowerCase();
200
202
  var allowedTagNames = (0, _keys.default)(allowedTags);
201
- if ((0, _includes2.default)(allowedTagNames, nodeName)) {
203
+ if ((0, _lodash.includes)(allowedTagNames, nodeName)) {
202
204
  var allowedAttributes = allowedTags[nodeName];
203
- (0, _forEach2.default)(listAttributeNames(node.attributes), function (attrName) {
204
- if (!(0, _includes2.default)(allowedAttributes, attrName)) {
205
+ (0, _lodash.forEach)(listAttributeNames(node.attributes), function (attrName) {
206
+ if (!(0, _lodash.includes)(allowedAttributes, attrName)) {
205
207
  node.removeAttribute(attrName);
206
208
  } else if (attrName === 'href' || attrName === 'src') {
207
209
  var attrValue = node.attributes.getNamedItem(attrName).value.toLowerCase();
@@ -215,7 +217,7 @@ function _filterEscapeSync(processCallback, allowedTags, allowedStyles, html) {
215
217
  } else if (attrName === 'style') {
216
218
  var styles = node.attributes.getNamedItem('style').value.split(';').map(function (style) {
217
219
  var styleName = trim(style.split(':')[0]);
218
- if ((0, _includes2.default)(allowedStyles, styleName)) {
220
+ if ((0, _lodash.includes)(allowedStyles, styleName)) {
219
221
  return style;
220
222
  }
221
223
  return null;
@@ -274,7 +276,7 @@ function reparent(node) {
274
276
  * @returns {Array<string>}
275
277
  */
276
278
  function listAttributeNames(attributes) {
277
- return (0, _reduce2.default)(attributes, function (attrNames, attr) {
279
+ return (0, _lodash.reduce)(attributes, function (attrNames, attr) {
278
280
  attrNames.push(attr.name);
279
281
  return attrNames;
280
282
  }, []);
@@ -320,7 +322,7 @@ function isElement(o) {
320
322
  * @param {string} html html to filter
321
323
  * @returns {string}
322
324
  */
323
- var filterSync = (0, _curry2.default)(_filterSync, 4);
325
+ var filterSync = exports.filterSync = (0, _lodash.curry)(_filterSync, 4);
324
326
 
325
327
  /**
326
328
  * Curried HTML filter that escapes rather than removes disallowed tags
@@ -329,8 +331,7 @@ var filterSync = (0, _curry2.default)(_filterSync, 4);
329
331
  * @param {string} html html to filter
330
332
  * @returns {Promise<string>}
331
333
  */
332
- exports.filterSync = filterSync;
333
- var filterEscape = (0, _curry2.default)(_filterEscape, 4);
334
+ var filterEscape = exports.filterEscape = (0, _lodash.curry)(_filterEscape, 4);
334
335
 
335
336
  /**
336
337
  * Curried HTML filter that escapes rather than removes disallowed tags
@@ -339,7 +340,5 @@ var filterEscape = (0, _curry2.default)(_filterEscape, 4);
339
340
  * @param {string} html html to filter
340
341
  * @returns {string}
341
342
  */
342
- exports.filterEscape = filterEscape;
343
- var filterEscapeSync = (0, _curry2.default)(_filterEscapeSync, 4);
344
- exports.filterEscapeSync = filterEscapeSync;
343
+ var filterEscapeSync = exports.filterEscapeSync = (0, _lodash.curry)(_filterEscapeSync, 4);
345
344
  //# sourceMappingURL=html.shim.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["removeNode","node","remove","parentElement","removeChild","i","length","Error","_filter","args","resolve","_filterSync","filter","processCallback","allowedTags","allowedStyles","html","doc","DOMParser","parseFromString","depthFirstForEach","body","childNodes","filterNode","indexOf","innerHTML","isElement","nodeName","toLowerCase","allowedTagNames","allowedAttributes","listAttributeNames","attributes","attrName","removeAttribute","attrValue","getNamedItem","value","trim","reparent","styles","split","map","style","styleName","Boolean","join","setAttribute","_filterEscape","_filterEscapeSync","escapeNode","before","document","createTextNode","after","parentNode","insertBefore","trimPattern","str","replace","attrNames","attr","push","name","list","fn","o","ownerDocument","undefined","nodeType","filterSync","filterEscape","filterEscapeSync"],"sources":["html.shim.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-env browser */\n\nimport {curry, forEach, includes, reduce} from 'lodash';\n\nexport {escape, escapeSync} from './html-base';\n\n/**\n * Some browsers don't implement {@link Element#remove()} or\n * {@link NodeList#remove()} or {@link HTMLCollection#remove()}. This wrapper\n * calls the appropriate `#remove()` method if available, or falls back to a\n * non-global-polluting polyfill.\n * @param {Element|NodeList|HTMLCollection} node\n * @returns {undefined}\n */\nfunction removeNode(node) {\n if (node.remove) {\n node.remove();\n\n return;\n }\n\n if (node.parentElement) {\n node.parentElement.removeChild(node);\n\n return;\n }\n\n if ('length' in node) {\n for (let i = node.length - 1; i >= 0; i -= 1) {\n removeNode(node[i]);\n }\n\n return;\n }\n\n throw new Error('Could not find a way to remove node');\n}\n\n/**\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @private\n * @returns {string}\n */\nfunction _filter(...args) {\n return new Promise((resolve) => {\n resolve(_filterSync(...args));\n });\n}\n\n/**\n * Curried async HTML filter.\n * @param {Object} allowedTags Map of tagName -> array of allowed attributes\n * @param {Array<string>} allowedStyles Array of allowed styles\n * @param {string} html html to filter\n * @returns {string}\n */\nexport const filter = curry(_filter, 4);\n\n/**\n * @param {function} processCallback callback function to do additional\n * processing on node. of the form process(node)\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @private\n * @returns {string}\n */\nfunction _filterSync(processCallback, allowedTags, allowedStyles, html) {\n if (!html || !allowedStyles || !allowedTags) {\n if (html.length === 0) {\n return html;\n }\n\n throw new Error('`allowedTags`, `allowedStyles`, and `html` must be provided');\n }\n\n const doc = new DOMParser().parseFromString(html, 'text/html');\n\n depthFirstForEach(doc.body.childNodes, filterNode);\n processCallback(doc.body);\n\n if (html.indexOf('body') === 1) {\n return `<body>${doc.body.innerHTML}</body>`;\n }\n\n return doc.body.innerHTML;\n\n /**\n * @param {Node} node\n * @private\n * @returns {undefined}\n */\n function filterNode(node) {\n if (!isElement(node)) {\n return;\n }\n\n const nodeName = node.nodeName.toLowerCase();\n const allowedTagNames = Object.keys(allowedTags);\n\n depthFirstForEach(node.childNodes, filterNode);\n\n if (includes(allowedTagNames, nodeName)) {\n const allowedAttributes = allowedTags[nodeName];\n\n forEach(listAttributeNames(node.attributes), (attrName) => {\n if (!includes(allowedAttributes, attrName)) {\n node.removeAttribute(attrName);\n } else if (attrName === 'href' || attrName === 'src') {\n const attrValue = node.attributes.getNamedItem(attrName).value.trim().toLowerCase();\n\n // We're doing at runtime what the no-script-url rule does at compile\n // time\n // eslint-disable-next-line no-script-url\n if (attrValue.indexOf('javascript:') === 0 || attrValue.indexOf('vbscript:') === 0) {\n reparent(node);\n }\n } else if (attrName === 'style') {\n const styles = node.attributes\n .getNamedItem('style')\n .value.split(';')\n .map((style) => {\n const styleName = trim(style.split(':')[0]);\n\n if (includes(allowedStyles, styleName)) {\n return style;\n }\n\n return null;\n })\n .filter((style) => Boolean(style))\n .join(';');\n\n node.setAttribute('style', styles);\n }\n });\n } else {\n reparent(node);\n }\n }\n}\n\n/**\n * Same as _filter, but escapes rather than removes disallowed values\n * @param {Function} processCallback\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @returns {Promise<string>}\n */\nfunction _filterEscape(...args) {\n return new Promise((resolve) => {\n resolve(_filterEscapeSync(...args));\n });\n}\n\n/**\n * Same as _filterSync, but escapes rather than removes disallowed values\n * @param {Function} processCallback\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @returns {string}\n */\nfunction _filterEscapeSync(processCallback, allowedTags, allowedStyles, html) {\n if (!html || !allowedStyles || !allowedTags) {\n if (html.length === 0) {\n return html;\n }\n\n throw new Error('`allowedTags`, `allowedStyles`, and `html` must be provided');\n }\n\n const doc = new DOMParser().parseFromString(html, 'text/html');\n\n depthFirstForEach(doc.body.childNodes, filterNode);\n processCallback(doc.body);\n\n if (html.indexOf('body') === 1) {\n return `<body>${doc.body.innerHTML}</body>`;\n }\n\n return doc.body.innerHTML;\n\n /**\n * @param {Node} node\n * @private\n * @returns {undefined}\n */\n function filterNode(node) {\n if (!isElement(node)) {\n return;\n }\n\n depthFirstForEach(node.childNodes, filterNode);\n\n const nodeName = node.nodeName.toLowerCase();\n const allowedTagNames = Object.keys(allowedTags);\n\n if (includes(allowedTagNames, nodeName)) {\n const allowedAttributes = allowedTags[nodeName];\n\n forEach(listAttributeNames(node.attributes), (attrName) => {\n if (!includes(allowedAttributes, attrName)) {\n node.removeAttribute(attrName);\n } else if (attrName === 'href' || attrName === 'src') {\n const attrValue = node.attributes.getNamedItem(attrName).value.toLowerCase();\n\n // We're doing at runtime what the no-script-url rule does at compile\n // time\n // eslint-disable-next-line no-script-url\n if (attrValue.indexOf('javascript:') === 0 || attrValue.indexOf('vbscript:') === 0) {\n reparent(node);\n }\n } else if (attrName === 'style') {\n const styles = node.attributes\n .getNamedItem('style')\n .value.split(';')\n .map((style) => {\n const styleName = trim(style.split(':')[0]);\n\n if (includes(allowedStyles, styleName)) {\n return style;\n }\n\n return null;\n })\n .filter((style) => Boolean(style))\n .join(';');\n\n node.setAttribute('style', styles);\n }\n });\n } else {\n escapeNode(node);\n }\n }\n}\n\n/**\n * Escapes a given html node\n * @param {Node} node\n * @returns {undefined}\n */\nfunction escapeNode(node) {\n const before = document.createTextNode(`<${node.nodeName.toLowerCase()}>`);\n const after = document.createTextNode(`</${node.nodeName.toLowerCase()}>`);\n\n node.parentNode.insertBefore(before, node);\n while (node.childNodes.length > 0) {\n node.parentNode.insertBefore(node.childNodes[0], node);\n }\n node.parentNode.insertBefore(after, node);\n\n removeNode(node);\n}\n\nconst trimPattern = /^\\s|\\s$/g;\n\n/**\n * @param {string} str\n * @returns {string}\n */\nfunction trim(str) {\n return str.replace(trimPattern, '');\n}\n\n/**\n * @param {Node} node\n * @private\n * @returns {undefined}\n */\nfunction reparent(node) {\n while (node.childNodes.length > 0) {\n node.parentNode.insertBefore(node.childNodes[0], node);\n }\n removeNode(node);\n}\n\n/**\n * @param {NamedNodeMap} attributes\n * @private\n * @returns {Array<string>}\n */\nfunction listAttributeNames(attributes) {\n return reduce(\n attributes,\n (attrNames, attr) => {\n attrNames.push(attr.name);\n\n return attrNames;\n },\n []\n );\n}\n\n/**\n * @param {Array} list\n * @param {Function} fn\n * @private\n * @returns {undefined}\n */\nfunction depthFirstForEach(list, fn) {\n for (let i = list.length; i >= 0; i -= 1) {\n fn(list[i]);\n }\n}\n\n/**\n * @param {Node} o\n * @private\n * @returns {Boolean}\n */\nfunction isElement(o) {\n if (!o) {\n return false;\n }\n\n if (o.ownerDocument === undefined) {\n return false;\n }\n\n if (o.nodeType !== 1) {\n return false;\n }\n\n if (typeof o.nodeName !== 'string') {\n return false;\n }\n\n return true;\n}\n\n/**\n * Curried HTML filter.\n * @param {Object} allowedTags Map of tagName -> array of allowed attributes\n * @param {Array<string>} allowedStyles Array of allowed styles\n * @param {string} html html to filter\n * @returns {string}\n */\nexport const filterSync = curry(_filterSync, 4);\n\n/**\n * Curried HTML filter that escapes rather than removes disallowed tags\n * @param {Object} allowedTags Map of tagName -> array of allowed attributes\n * @param {Array<string>} allowedStyles Array of allowed styles\n * @param {string} html html to filter\n * @returns {Promise<string>}\n */\nexport const filterEscape = curry(_filterEscape, 4);\n\n/**\n * Curried HTML filter that escapes rather than removes disallowed tags\n * @param {Object} allowedTags Map of tagName -> array of allowed attributes\n * @param {Array<string>} allowedStyles Array of allowed styles\n * @param {string} html html to filter\n * @returns {string}\n */\nexport const filterEscapeSync = curry(_filterEscapeSync, 4);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,CAACC,IAAI,EAAE;EACxB,IAAIA,IAAI,CAACC,MAAM,EAAE;IACfD,IAAI,CAACC,MAAM,EAAE;IAEb;EACF;EAEA,IAAID,IAAI,CAACE,aAAa,EAAE;IACtBF,IAAI,CAACE,aAAa,CAACC,WAAW,CAACH,IAAI,CAAC;IAEpC;EACF;EAEA,IAAI,QAAQ,IAAIA,IAAI,EAAE;IACpB,KAAK,IAAII,CAAC,GAAGJ,IAAI,CAACK,MAAM,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAEA,CAAC,IAAI,CAAC,EAAE;MAC5CL,UAAU,CAACC,IAAI,CAACI,CAAC,CAAC,CAAC;IACrB;IAEA;EACF;EAEA,MAAM,IAAIE,KAAK,CAAC,qCAAqC,CAAC;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,OAAO,GAAU;EAAA,kCAANC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
1
+ {"version":3,"names":["_lodash","require","_htmlBase","removeNode","node","remove","parentElement","removeChild","i","length","Error","_filter","_len","arguments","args","Array","_key","_promise","default","resolve","_filterSync","apply","filter","exports","curry","processCallback","allowedTags","allowedStyles","html","doc","DOMParser","parseFromString","depthFirstForEach","body","childNodes","filterNode","indexOf","concat","innerHTML","isElement","nodeName","toLowerCase","allowedTagNames","_keys","includes","allowedAttributes","forEach","listAttributeNames","attributes","attrName","removeAttribute","attrValue","getNamedItem","value","trim","reparent","styles","split","map","style","styleName","Boolean","join","setAttribute","_filterEscape","_len2","_key2","_filterEscapeSync","escapeNode","before","document","createTextNode","after","parentNode","insertBefore","trimPattern","str","replace","reduce","attrNames","attr","push","name","list","fn","o","ownerDocument","undefined","nodeType","filterSync","filterEscape","filterEscapeSync"],"sources":["html.shim.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-env browser */\n\nimport {curry, forEach, includes, reduce} from 'lodash';\n\nexport {escape, escapeSync} from './html-base';\n\n/**\n * Some browsers don't implement {@link Element#remove()} or\n * {@link NodeList#remove()} or {@link HTMLCollection#remove()}. This wrapper\n * calls the appropriate `#remove()` method if available, or falls back to a\n * non-global-polluting polyfill.\n * @param {Element|NodeList|HTMLCollection} node\n * @returns {undefined}\n */\nfunction removeNode(node) {\n if (node.remove) {\n node.remove();\n\n return;\n }\n\n if (node.parentElement) {\n node.parentElement.removeChild(node);\n\n return;\n }\n\n if ('length' in node) {\n for (let i = node.length - 1; i >= 0; i -= 1) {\n removeNode(node[i]);\n }\n\n return;\n }\n\n throw new Error('Could not find a way to remove node');\n}\n\n/**\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @private\n * @returns {string}\n */\nfunction _filter(...args) {\n return new Promise((resolve) => {\n resolve(_filterSync(...args));\n });\n}\n\n/**\n * Curried async HTML filter.\n * @param {Object} allowedTags Map of tagName -> array of allowed attributes\n * @param {Array<string>} allowedStyles Array of allowed styles\n * @param {string} html html to filter\n * @returns {string}\n */\nexport const filter = curry(_filter, 4);\n\n/**\n * @param {function} processCallback callback function to do additional\n * processing on node. of the form process(node)\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @private\n * @returns {string}\n */\nfunction _filterSync(processCallback, allowedTags, allowedStyles, html) {\n if (!html || !allowedStyles || !allowedTags) {\n if (html.length === 0) {\n return html;\n }\n\n throw new Error('`allowedTags`, `allowedStyles`, and `html` must be provided');\n }\n\n const doc = new DOMParser().parseFromString(html, 'text/html');\n\n depthFirstForEach(doc.body.childNodes, filterNode);\n processCallback(doc.body);\n\n if (html.indexOf('body') === 1) {\n return `<body>${doc.body.innerHTML}</body>`;\n }\n\n return doc.body.innerHTML;\n\n /**\n * @param {Node} node\n * @private\n * @returns {undefined}\n */\n function filterNode(node) {\n if (!isElement(node)) {\n return;\n }\n\n const nodeName = node.nodeName.toLowerCase();\n const allowedTagNames = Object.keys(allowedTags);\n\n depthFirstForEach(node.childNodes, filterNode);\n\n if (includes(allowedTagNames, nodeName)) {\n const allowedAttributes = allowedTags[nodeName];\n\n forEach(listAttributeNames(node.attributes), (attrName) => {\n if (!includes(allowedAttributes, attrName)) {\n node.removeAttribute(attrName);\n } else if (attrName === 'href' || attrName === 'src') {\n const attrValue = node.attributes.getNamedItem(attrName).value.trim().toLowerCase();\n\n // We're doing at runtime what the no-script-url rule does at compile\n // time\n // eslint-disable-next-line no-script-url\n if (attrValue.indexOf('javascript:') === 0 || attrValue.indexOf('vbscript:') === 0) {\n reparent(node);\n }\n } else if (attrName === 'style') {\n const styles = node.attributes\n .getNamedItem('style')\n .value.split(';')\n .map((style) => {\n const styleName = trim(style.split(':')[0]);\n\n if (includes(allowedStyles, styleName)) {\n return style;\n }\n\n return null;\n })\n .filter((style) => Boolean(style))\n .join(';');\n\n node.setAttribute('style', styles);\n }\n });\n } else {\n reparent(node);\n }\n }\n}\n\n/**\n * Same as _filter, but escapes rather than removes disallowed values\n * @param {Function} processCallback\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @returns {Promise<string>}\n */\nfunction _filterEscape(...args) {\n return new Promise((resolve) => {\n resolve(_filterEscapeSync(...args));\n });\n}\n\n/**\n * Same as _filterSync, but escapes rather than removes disallowed values\n * @param {Function} processCallback\n * @param {Object} allowedTags\n * @param {Array<string>} allowedStyles\n * @param {string} html\n * @returns {string}\n */\nfunction _filterEscapeSync(processCallback, allowedTags, allowedStyles, html) {\n if (!html || !allowedStyles || !allowedTags) {\n if (html.length === 0) {\n return html;\n }\n\n throw new Error('`allowedTags`, `allowedStyles`, and `html` must be provided');\n }\n\n const doc = new DOMParser().parseFromString(html, 'text/html');\n\n depthFirstForEach(doc.body.childNodes, filterNode);\n processCallback(doc.body);\n\n if (html.indexOf('body') === 1) {\n return `<body>${doc.body.innerHTML}</body>`;\n }\n\n return doc.body.innerHTML;\n\n /**\n * @param {Node} node\n * @private\n * @returns {undefined}\n */\n function filterNode(node) {\n if (!isElement(node)) {\n return;\n }\n\n depthFirstForEach(node.childNodes, filterNode);\n\n const nodeName = node.nodeName.toLowerCase();\n const allowedTagNames = Object.keys(allowedTags);\n\n if (includes(allowedTagNames, nodeName)) {\n const allowedAttributes = allowedTags[nodeName];\n\n forEach(listAttributeNames(node.attributes), (attrName) => {\n if (!includes(allowedAttributes, attrName)) {\n node.removeAttribute(attrName);\n } else if (attrName === 'href' || attrName === 'src') {\n const attrValue = node.attributes.getNamedItem(attrName).value.toLowerCase();\n\n // We're doing at runtime what the no-script-url rule does at compile\n // time\n // eslint-disable-next-line no-script-url\n if (attrValue.indexOf('javascript:') === 0 || attrValue.indexOf('vbscript:') === 0) {\n reparent(node);\n }\n } else if (attrName === 'style') {\n const styles = node.attributes\n .getNamedItem('style')\n .value.split(';')\n .map((style) => {\n const styleName = trim(style.split(':')[0]);\n\n if (includes(allowedStyles, styleName)) {\n return style;\n }\n\n return null;\n })\n .filter((style) => Boolean(style))\n .join(';');\n\n node.setAttribute('style', styles);\n }\n });\n } else {\n escapeNode(node);\n }\n }\n}\n\n/**\n * Escapes a given html node\n * @param {Node} node\n * @returns {undefined}\n */\nfunction escapeNode(node) {\n const before = document.createTextNode(`<${node.nodeName.toLowerCase()}>`);\n const after = document.createTextNode(`</${node.nodeName.toLowerCase()}>`);\n\n node.parentNode.insertBefore(before, node);\n while (node.childNodes.length > 0) {\n node.parentNode.insertBefore(node.childNodes[0], node);\n }\n node.parentNode.insertBefore(after, node);\n\n removeNode(node);\n}\n\nconst trimPattern = /^\\s|\\s$/g;\n\n/**\n * @param {string} str\n * @returns {string}\n */\nfunction trim(str) {\n return str.replace(trimPattern, '');\n}\n\n/**\n * @param {Node} node\n * @private\n * @returns {undefined}\n */\nfunction reparent(node) {\n while (node.childNodes.length > 0) {\n node.parentNode.insertBefore(node.childNodes[0], node);\n }\n removeNode(node);\n}\n\n/**\n * @param {NamedNodeMap} attributes\n * @private\n * @returns {Array<string>}\n */\nfunction listAttributeNames(attributes) {\n return reduce(\n attributes,\n (attrNames, attr) => {\n attrNames.push(attr.name);\n\n return attrNames;\n },\n []\n );\n}\n\n/**\n * @param {Array} list\n * @param {Function} fn\n * @private\n * @returns {undefined}\n */\nfunction depthFirstForEach(list, fn) {\n for (let i = list.length; i >= 0; i -= 1) {\n fn(list[i]);\n }\n}\n\n/**\n * @param {Node} o\n * @private\n * @returns {Boolean}\n */\nfunction isElement(o) {\n if (!o) {\n return false;\n }\n\n if (o.ownerDocument === undefined) {\n return false;\n }\n\n if (o.nodeType !== 1) {\n return false;\n }\n\n if (typeof o.nodeName !== 'string') {\n return false;\n }\n\n return true;\n}\n\n/**\n * Curried HTML filter.\n * @param {Object} allowedTags Map of tagName -> array of allowed attributes\n * @param {Array<string>} allowedStyles Array of allowed styles\n * @param {string} html html to filter\n * @returns {string}\n */\nexport const filterSync = curry(_filterSync, 4);\n\n/**\n * Curried HTML filter that escapes rather than removes disallowed tags\n * @param {Object} allowedTags Map of tagName -> array of allowed attributes\n * @param {Array<string>} allowedStyles Array of allowed styles\n * @param {string} html html to filter\n * @returns {Promise<string>}\n */\nexport const filterEscape = curry(_filterEscape, 4);\n\n/**\n * Curried HTML filter that escapes rather than removes disallowed tags\n * @param {Object} allowedTags Map of tagName -> array of allowed attributes\n * @param {Array<string>} allowedStyles Array of allowed styles\n * @param {string} html html to filter\n * @returns {string}\n */\nexport const filterEscapeSync = curry(_filterEscapeSync, 4);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAMA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAEA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,UAAUA,CAACC,IAAI,EAAE;EACxB,IAAIA,IAAI,CAACC,MAAM,EAAE;IACfD,IAAI,CAACC,MAAM,CAAC,CAAC;IAEb;EACF;EAEA,IAAID,IAAI,CAACE,aAAa,EAAE;IACtBF,IAAI,CAACE,aAAa,CAACC,WAAW,CAACH,IAAI,CAAC;IAEpC;EACF;EAEA,IAAI,QAAQ,IAAIA,IAAI,EAAE;IACpB,KAAK,IAAII,CAAC,GAAGJ,IAAI,CAACK,MAAM,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAEA,CAAC,IAAI,CAAC,EAAE;MAC5CL,UAAU,CAACC,IAAI,CAACI,CAAC,CAAC,CAAC;IACrB;IAEA;EACF;EAEA,MAAM,IAAIE,KAAK,CAAC,qCAAqC,CAAC;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,OAAOA,CAAA,EAAU;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAJ,MAAA,EAANK,IAAI,OAAAC,KAAA,CAAAH,IAAA,GAAAI,IAAA,MAAAA,IAAA,GAAAJ,IAAA,EAAAI,IAAA;IAAJF,IAAI,CAAAE,IAAA,IAAAH,SAAA,CAAAG,IAAA;EAAA;EACtB,OAAO,IAAAC,QA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;EACd;EAEA,IAAIA,CAAC,CAACC,aAAa,KAAKC,SAAS,EAAE;IACjC,OAAO,KAAK;EACd;EAEA,IAAIF,CAAC,CAACG,QAAQ,KAAK,CAAC,EAAE;IACpB,OAAO,KAAK;EACd;EAEA,IAAI,OAAOH,CAAC,CAAC7C,QAAQ,KAAK,QAAQ,EAAE;IAClC,OAAO,KAAK;EACd;EAEA,OAAO,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMiD,UAAU,GAAAlE,OAAA,CAAAkE,UAAA,GAAG,IAAAjE,aAAK,EAACJ,WAAW,EAAE,CAAC,CAAC;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMsE,YAAY,GAAAnE,OAAA,CAAAmE,YAAA,GAAG,IAAAlE,aAAK,EAACwC,aAAa,EAAE,CAAC,CAAC;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAM2B,gBAAgB,GAAApE,OAAA,CAAAoE,gBAAA,GAAG,IAAAnE,aAAK,EAAC2C,iBAAiB,EAAE,CAAC,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nexport {escape, escapeSync, filter, filterSync, filterEscape, filterEscapeSync} from './html';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA"}
1
+ {"version":3,"names":["_html","require"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nexport {escape, escapeSync, filter, filterSync, filterEscape, filterEscapeSync} from './html';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA"}
package/jest.config.js ADDED
@@ -0,0 +1,3 @@
1
+ const config = require('@webex/jest-config-legacy');
2
+
3
+ module.exports = config;
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "@webex/helper-html",
3
- "version": "3.0.0-bnr.4",
4
3
  "description": "HTML Utiltities",
5
4
  "license": "MIT",
6
5
  "main": "dist/index.js",
@@ -24,11 +23,28 @@
24
23
  ]
25
24
  },
26
25
  "devDependencies": {
27
- "@webex/test-helper-chai": "workspace:^",
28
- "@webex/test-helper-mocha": "workspace:^"
26
+ "@babel/core": "^7.17.10",
27
+ "@webex/babel-config-legacy": "0.0.0",
28
+ "@webex/eslint-config-legacy": "0.0.0",
29
+ "@webex/jest-config-legacy": "0.0.0",
30
+ "@webex/legacy-tools": "0.0.0",
31
+ "@webex/test-helper-chai": "3.0.0",
32
+ "@webex/test-helper-mocha": "3.0.0",
33
+ "@webex/test-helper-mock-webex": "3.0.0",
34
+ "@webex/test-helper-test-users": "3.0.0",
35
+ "eslint": "^8.24.0",
36
+ "prettier": "^2.7.1"
29
37
  },
30
38
  "dependencies": {
31
- "@webex/helper-html": "workspace:^",
32
39
  "lodash": "^4.17.21"
33
- }
34
- }
40
+ },
41
+ "scripts": {
42
+ "build": "yarn build:src",
43
+ "build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
44
+ "deploy:npm": "yarn npm publish",
45
+ "test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
46
+ "test:browser": "webex-legacy-tools test --unit --runner karma",
47
+ "test:style": "eslint ./src/**/*.*"
48
+ },
49
+ "version": "3.0.0"
50
+ }
package/process ADDED
@@ -0,0 +1 @@
1
+ module.exports = {browser: true};
@@ -1,12 +0,0 @@
1
- /**
2
- * Escapes HTML
3
- * @param {[type]} html
4
- * @returns {[type]}
5
- */
6
- export function escape(html: [type]): [type];
7
- /**
8
- * Synchronously escape HTML
9
- * @param {[type]} html
10
- * @returns {[type]}
11
- */
12
- export function escapeSync(html: [type]): [type];
@@ -1,5 +0,0 @@
1
- export const filter: import("lodash").CurriedFunction1<any, string>;
2
- export const filterSync: import("lodash").CurriedFunction4<Function, any, string[], string, string>;
3
- export const filterEscape: import("lodash").CurriedFunction1<any, string>;
4
- export const filterEscapeSync: import("lodash").CurriedFunction4<Function, any, string[], string, string>;
5
- export { escape, escapeSync } from "./html-base";
@@ -1,33 +0,0 @@
1
- /**
2
- * Curried async HTML filter.
3
- * @param {Object} allowedTags Map of tagName -> array of allowed attributes
4
- * @param {Array<string>} allowedStyles Array of allowed styles
5
- * @param {string} html html to filter
6
- * @returns {string}
7
- */
8
- export const filter: import("lodash").CurriedFunction1<any, string>;
9
- /**
10
- * Curried HTML filter.
11
- * @param {Object} allowedTags Map of tagName -> array of allowed attributes
12
- * @param {Array<string>} allowedStyles Array of allowed styles
13
- * @param {string} html html to filter
14
- * @returns {string}
15
- */
16
- export const filterSync: import("lodash").CurriedFunction4<Function, any, string[], string, string>;
17
- /**
18
- * Curried HTML filter that escapes rather than removes disallowed tags
19
- * @param {Object} allowedTags Map of tagName -> array of allowed attributes
20
- * @param {Array<string>} allowedStyles Array of allowed styles
21
- * @param {string} html html to filter
22
- * @returns {Promise<string>}
23
- */
24
- export const filterEscape: import("lodash").CurriedFunction1<any, Promise<string>>;
25
- /**
26
- * Curried HTML filter that escapes rather than removes disallowed tags
27
- * @param {Object} allowedTags Map of tagName -> array of allowed attributes
28
- * @param {Array<string>} allowedStyles Array of allowed styles
29
- * @param {string} html html to filter
30
- * @returns {string}
31
- */
32
- export const filterEscapeSync: import("lodash").CurriedFunction4<Function, any, string[], string, string>;
33
- export { escape, escapeSync } from "./html-base";
@@ -1 +0,0 @@
1
- export { escape, escapeSync, filter, filterSync, filterEscape, filterEscapeSync } from "./html";