@webex/helper-html 2.59.3-next.1 → 2.59.4-next.1
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 +6 -6
- package/README.md +62 -62
- package/babel.config.js +3 -3
- package/browsers.js +18 -18
- package/dist/html-base.js +14 -14
- package/dist/html-base.js.map +1 -1
- package/dist/html.js +23 -19
- package/dist/html.js.map +1 -1
- package/dist/html.shim.js +111 -108
- package/dist/html.shim.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +5 -5
- package/process +1 -1
- package/src/html-base.js +44 -44
- package/src/html.js +38 -38
- package/src/html.shim.js +365 -365
- package/src/index.js +5 -5
- package/test/unit/spec/html.js +286 -286
package/.eslintrc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const config = {
|
|
2
|
-
root: true,
|
|
3
|
-
extends: ['@webex/eslint-config-legacy'],
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
module.exports = config;
|
|
1
|
+
const config = {
|
|
2
|
+
root: true,
|
|
3
|
+
extends: ['@webex/eslint-config-legacy'],
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
module.exports = config;
|
package/README.md
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
# @webex/helper-html
|
|
2
|
-
|
|
3
|
-
[](https://github.com/RichardLitt/standard-readme)
|
|
4
|
-
|
|
5
|
-
> HTML filter for the Cisco Webex JS SDK. See https://webex.github.io/webex-js-sdk/
|
|
6
|
-
|
|
7
|
-
Note: This package relies on DOM apis and largely returns noops in node environments.
|
|
8
|
-
|
|
9
|
-
- [Install](#install)
|
|
10
|
-
- [Usage](#usage)
|
|
11
|
-
- [Contribute](#contribute)
|
|
12
|
-
- [Maintainers](#maintainers)
|
|
13
|
-
- [License](#license)
|
|
14
|
-
|
|
15
|
-
## Install
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install --save @webex/helper-html
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
### `filter(allowedTags, allowedStyles, html)`
|
|
24
|
-
|
|
25
|
-
Filters an html string such that it only includes the allowed tags and styles. Disallowed tags and styles are removed while their contents are kept.
|
|
26
|
-
|
|
27
|
-
`allowedTags` is an object keyed on tag name mapped to an array of attribuets allowed for that tag.
|
|
28
|
-
`allwedStyles` is an array of allowed style string.
|
|
29
|
-
`html` is a string.
|
|
30
|
-
|
|
31
|
-
Returns a promise that resolves with the new html string.
|
|
32
|
-
|
|
33
|
-
### `filterSync()`
|
|
34
|
-
|
|
35
|
-
See `filter()`
|
|
36
|
-
|
|
37
|
-
### `filterEscape(processCallback, allowedTags, allowedStyles, html)`
|
|
38
|
-
|
|
39
|
-
Filters an html string such that it only includes the allowed tags and styles. Disallowed tags and styles and their children are escaped.
|
|
40
|
-
|
|
41
|
-
`processCallback` synchronous callback that receives the body of the html fragment generated from `html`. Presents an opportunity to do preprocessing (e.g turn urls into links) without parsing html `mulitple` times
|
|
42
|
-
`allowedTags` is an object keyed on tag name mapped to an array of attribuets allowed for that tag.
|
|
43
|
-
`allwedStyles` is an array of allowed style string.
|
|
44
|
-
`html` is a string.
|
|
45
|
-
|
|
46
|
-
Returns a promise that resolves with the new html string.
|
|
47
|
-
|
|
48
|
-
### `filterEscapeSync()`
|
|
49
|
-
|
|
50
|
-
See `filterEscape()`
|
|
51
|
-
|
|
52
|
-
## Maintainers
|
|
53
|
-
|
|
54
|
-
This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
|
|
55
|
-
|
|
56
|
-
## Contribute
|
|
57
|
-
|
|
58
|
-
Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
|
|
59
|
-
|
|
60
|
-
## License
|
|
61
|
-
|
|
62
|
-
© 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
|
|
1
|
+
# @webex/helper-html
|
|
2
|
+
|
|
3
|
+
[](https://github.com/RichardLitt/standard-readme)
|
|
4
|
+
|
|
5
|
+
> HTML filter for the Cisco Webex JS SDK. See https://webex.github.io/webex-js-sdk/
|
|
6
|
+
|
|
7
|
+
Note: This package relies on DOM apis and largely returns noops in node environments.
|
|
8
|
+
|
|
9
|
+
- [Install](#install)
|
|
10
|
+
- [Usage](#usage)
|
|
11
|
+
- [Contribute](#contribute)
|
|
12
|
+
- [Maintainers](#maintainers)
|
|
13
|
+
- [License](#license)
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save @webex/helper-html
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### `filter(allowedTags, allowedStyles, html)`
|
|
24
|
+
|
|
25
|
+
Filters an html string such that it only includes the allowed tags and styles. Disallowed tags and styles are removed while their contents are kept.
|
|
26
|
+
|
|
27
|
+
`allowedTags` is an object keyed on tag name mapped to an array of attribuets allowed for that tag.
|
|
28
|
+
`allwedStyles` is an array of allowed style string.
|
|
29
|
+
`html` is a string.
|
|
30
|
+
|
|
31
|
+
Returns a promise that resolves with the new html string.
|
|
32
|
+
|
|
33
|
+
### `filterSync()`
|
|
34
|
+
|
|
35
|
+
See `filter()`
|
|
36
|
+
|
|
37
|
+
### `filterEscape(processCallback, allowedTags, allowedStyles, html)`
|
|
38
|
+
|
|
39
|
+
Filters an html string such that it only includes the allowed tags and styles. Disallowed tags and styles and their children are escaped.
|
|
40
|
+
|
|
41
|
+
`processCallback` synchronous callback that receives the body of the html fragment generated from `html`. Presents an opportunity to do preprocessing (e.g turn urls into links) without parsing html `mulitple` times
|
|
42
|
+
`allowedTags` is an object keyed on tag name mapped to an array of attribuets allowed for that tag.
|
|
43
|
+
`allwedStyles` is an array of allowed style string.
|
|
44
|
+
`html` is a string.
|
|
45
|
+
|
|
46
|
+
Returns a promise that resolves with the new html string.
|
|
47
|
+
|
|
48
|
+
### `filterEscapeSync()`
|
|
49
|
+
|
|
50
|
+
See `filterEscape()`
|
|
51
|
+
|
|
52
|
+
## Maintainers
|
|
53
|
+
|
|
54
|
+
This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
|
|
55
|
+
|
|
56
|
+
## Contribute
|
|
57
|
+
|
|
58
|
+
Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
© 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
|
package/babel.config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const babelConfigLegacy = require('@webex/babel-config-legacy');
|
|
2
|
-
|
|
3
|
-
module.exports = babelConfigLegacy;
|
|
1
|
+
const babelConfigLegacy = require('@webex/babel-config-legacy');
|
|
2
|
+
|
|
3
|
+
module.exports = babelConfigLegacy;
|
package/browsers.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/* eslint-disable */
|
|
6
|
-
|
|
7
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
module.exports = function (browsers) {
|
|
10
|
-
// For reasons as-yet unexplained, the html filter test suite hangs when run
|
|
11
|
-
// on Safari/Sauce Labs
|
|
12
|
-
Object.keys(browsers).forEach(function (key) {
|
|
13
|
-
if (key.indexOf('safari') !== -1) {
|
|
14
|
-
delete browsers[key];
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return browsers;
|
|
18
|
-
};
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
module.exports = function (browsers) {
|
|
10
|
+
// For reasons as-yet unexplained, the html filter test suite hangs when run
|
|
11
|
+
// on Safari/Sauce Labs
|
|
12
|
+
Object.keys(browsers).forEach(function (key) {
|
|
13
|
+
if (key.indexOf('safari') !== -1) {
|
|
14
|
+
delete browsers[key];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return browsers;
|
|
18
|
+
};
|
package/dist/html-base.js
CHANGED
|
@@ -8,8 +8,8 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.escape = escape;
|
|
9
9
|
exports.escapeSync = escapeSync;
|
|
10
10
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
11
|
-
/*!
|
|
12
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
11
|
+
/*!
|
|
12
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
var escapeMe = /(<|>|&)/g;
|
|
@@ -17,10 +17,10 @@ var escapeMe = /(<|>|&)/g;
|
|
|
17
17
|
// escape and escapeSync probably don't both need to exist, but it seemed like a
|
|
18
18
|
// good idea in case we ever want to for the future.
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Escapes HTML
|
|
22
|
-
* @param {[type]} html
|
|
23
|
-
* @returns {[type]}
|
|
20
|
+
/**
|
|
21
|
+
* Escapes HTML
|
|
22
|
+
* @param {[type]} html
|
|
23
|
+
* @returns {[type]}
|
|
24
24
|
*/
|
|
25
25
|
function escape(html) {
|
|
26
26
|
return new _promise.default(function (resolve) {
|
|
@@ -28,19 +28,19 @@ function escape(html) {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
/**
|
|
32
|
-
* Synchronously escape HTML
|
|
33
|
-
* @param {[type]} html
|
|
34
|
-
* @returns {[type]}
|
|
31
|
+
/**
|
|
32
|
+
* Synchronously escape HTML
|
|
33
|
+
* @param {[type]} html
|
|
34
|
+
* @returns {[type]}
|
|
35
35
|
*/
|
|
36
36
|
function escapeSync(html) {
|
|
37
37
|
return html.replace(escapeMe, entityReplacer);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* @param {string} char
|
|
42
|
-
* @private
|
|
43
|
-
* @returns {string}
|
|
40
|
+
/**
|
|
41
|
+
* @param {string} char
|
|
42
|
+
* @private
|
|
43
|
+
* @returns {string}
|
|
44
44
|
*/
|
|
45
45
|
function entityReplacer(char) {
|
|
46
46
|
switch (char) {
|
package/dist/html-base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["escapeMe","escape","html","_promise","default","resolve","escapeSync","replace","entityReplacer","char"],"sources":["html-base.js"],"sourcesContent":["/*!\
|
|
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 '<';\n case '>':\n return '>';\n case '&':\n return '&';\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;EAAC;AAElB"}
|
package/dist/html.js
CHANGED
|
@@ -19,14 +19,18 @@ _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
|
|
22
|
+
var _lodash = require("lodash");
|
|
23
23
|
var _htmlBase = require("./html-base");
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* @
|
|
24
|
+
/*!
|
|
25
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {Object} allowedTags
|
|
30
|
+
* @param {Array<string>} allowedStyles
|
|
31
|
+
* @param {string} html
|
|
32
|
+
* @private
|
|
33
|
+
* @returns {string}
|
|
30
34
|
*/
|
|
31
35
|
function noop() {
|
|
32
36
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -37,24 +41,24 @@ function noop() {
|
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
/**
|
|
41
|
-
* @param {function} processCallback callback function to do additional
|
|
42
|
-
* processing on node. of the form process(node)
|
|
43
|
-
* @param {Object} allowedTags
|
|
44
|
-
* @param {Array<string>} allowedStyles
|
|
45
|
-
* @param {string} html
|
|
46
|
-
* @private
|
|
47
|
-
* @returns {string}
|
|
44
|
+
/**
|
|
45
|
+
* @param {function} processCallback callback function to do additional
|
|
46
|
+
* processing on node. of the form process(node)
|
|
47
|
+
* @param {Object} allowedTags
|
|
48
|
+
* @param {Array<string>} allowedStyles
|
|
49
|
+
* @param {string} html
|
|
50
|
+
* @private
|
|
51
|
+
* @returns {string}
|
|
48
52
|
*/
|
|
49
53
|
function noopSync(processCallback, allowedTags, allowedStyles, html) {
|
|
50
54
|
return html;
|
|
51
55
|
}
|
|
52
|
-
var filter = (0,
|
|
56
|
+
var filter = (0, _lodash.curry)(noop, 4);
|
|
53
57
|
exports.filter = filter;
|
|
54
|
-
var filterSync = (0,
|
|
58
|
+
var filterSync = (0, _lodash.curry)(noopSync, 4);
|
|
55
59
|
exports.filterSync = filterSync;
|
|
56
|
-
var filterEscape = (0,
|
|
60
|
+
var filterEscape = (0, _lodash.curry)(noop, 4);
|
|
57
61
|
exports.filterEscape = filterEscape;
|
|
58
|
-
var filterEscapeSync = (0,
|
|
62
|
+
var filterEscapeSync = (0, _lodash.curry)(noopSync, 4);
|
|
59
63
|
exports.filterEscapeSync = filterEscapeSync;
|
|
60
64
|
//# sourceMappingURL=html.js.map
|
package/dist/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_lodash","require","_htmlBase","noop","_len","arguments","length","args","Array","_key","_promise","default","resolve","noopSync","apply","processCallback","allowedTags","allowedStyles","html","filter","curry","exports","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,GAAG,IAAAC,aAAK,EAACjB,IAAI,EAAE,CAAC,CAAC;AAACkB,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAC9B,IAAMG,UAAU,GAAG,IAAAF,aAAK,EAACP,QAAQ,EAAE,CAAC,CAAC;AAACQ,OAAA,CAAAC,UAAA,GAAAA,UAAA;AACtC,IAAMC,YAAY,GAAG,IAAAH,aAAK,EAACjB,IAAI,EAAE,CAAC,CAAC;AAACkB,OAAA,CAAAE,YAAA,GAAAA,YAAA;AACpC,IAAMC,gBAAgB,GAAG,IAAAJ,aAAK,EAACP,QAAQ,EAAE,CAAC,CAAC;AAACQ,OAAA,CAAAG,gBAAA,GAAAA,gBAAA"}
|