avalynx-alert 1.0.6 → 1.0.7
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.
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* AvalynxAlert is a simple alert system for web applications. Based on Bootstrap >=5.3 without any framework dependencies.
|
|
5
5
|
*
|
|
6
|
-
* @version 1.0.
|
|
6
|
+
* @version 1.0.7
|
|
7
7
|
* @license MIT
|
|
8
8
|
* @author https://github.com/avalynx/avalynx-alert/graphs/contributors
|
|
9
9
|
* @website https://github.com/avalynx/
|
|
10
10
|
* @repository https://github.com/avalynx/avalynx-alert.git
|
|
11
11
|
* @bugs https://github.com/avalynx/avalynx-alert/issues
|
|
12
12
|
*
|
|
13
|
-
* @param {string} message - The message to display in the alert (default: '').
|
|
13
|
+
* @param {string} message - The message to display in the alert. HTML is escaped to prevent XSS (default: '').
|
|
14
14
|
* @param {string} type - The type of alert. One of 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark' (default: 'info').
|
|
15
15
|
* @param {object} options - An object containing the following keys:
|
|
16
16
|
* @param {number} options.duration - Duration in milliseconds for the alert to be displayed (default: 5000).
|
|
@@ -26,7 +26,7 @@ import * as bootstrap from 'bootstrap';
|
|
|
26
26
|
|
|
27
27
|
export class AvalynxAlert {
|
|
28
28
|
constructor(message, type, options = {}) {
|
|
29
|
-
this.message = message;
|
|
29
|
+
this.message = this.sanitize(message);
|
|
30
30
|
this.type = type;
|
|
31
31
|
if (options === null || typeof options !== 'object') {
|
|
32
32
|
options = {};
|
|
@@ -56,6 +56,12 @@ export class AvalynxAlert {
|
|
|
56
56
|
this.init();
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
sanitize(str) {
|
|
60
|
+
const temp = document.createElement('div');
|
|
61
|
+
temp.textContent = str;
|
|
62
|
+
return temp.innerHTML;
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
ensureAlertContainer() {
|
|
60
66
|
if (!document.getElementById('avalynx-alert-container-' + this.options.position)) {
|
|
61
67
|
var container = document.createElement('div');
|
package/dist/js/avalynx-alert.js
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* AvalynxAlert is a simple alert system for web applications. Based on Bootstrap >=5.3 without any framework dependencies.
|
|
5
5
|
*
|
|
6
|
-
* @version 1.0.
|
|
6
|
+
* @version 1.0.7
|
|
7
7
|
* @license MIT
|
|
8
8
|
* @author https://github.com/avalynx/avalynx-alert/graphs/contributors
|
|
9
9
|
* @website https://github.com/avalynx/
|
|
10
10
|
* @repository https://github.com/avalynx/avalynx-alert.git
|
|
11
11
|
* @bugs https://github.com/avalynx/avalynx-alert/issues
|
|
12
12
|
*
|
|
13
|
-
* @param {string} message - The message to display in the alert (default: '').
|
|
13
|
+
* @param {string} message - The message to display in the alert. HTML is escaped to prevent XSS (default: '').
|
|
14
14
|
* @param {string} type - The type of alert. One of 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark' (default: 'info').
|
|
15
15
|
* @param {object} options - An object containing the following keys:
|
|
16
16
|
* @param {number} options.duration - Duration in milliseconds for the alert to be displayed (default: 5000).
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
class AvalynxAlert {
|
|
26
26
|
constructor(message, type, options = {}) {
|
|
27
|
-
this.message = message;
|
|
27
|
+
this.message = this.sanitize(message);
|
|
28
28
|
this.type = type;
|
|
29
29
|
if (options === null || typeof options !== 'object') {
|
|
30
30
|
options = {};
|
|
@@ -54,6 +54,12 @@ class AvalynxAlert {
|
|
|
54
54
|
this.init();
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
sanitize(str) {
|
|
58
|
+
const temp = document.createElement('div');
|
|
59
|
+
temp.textContent = str;
|
|
60
|
+
return temp.innerHTML;
|
|
61
|
+
}
|
|
62
|
+
|
|
57
63
|
ensureAlertContainer() {
|
|
58
64
|
if (!document.getElementById('avalynx-alert-container-' + this.options.position)) {
|
|
59
65
|
var container = document.createElement('div');
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "avalynx-alert",
|
|
3
3
|
"title": "AvalynxAlert",
|
|
4
4
|
"description": "AvalynxAlert is a simple alert system for web applications. Based on Bootstrap >=5.3 without any framework dependencies.",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.7",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/js/avalynx-alert.js",
|
|
8
8
|
"module": "dist/js/avalynx-alert.esm.js",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"bootstrap": ">=5.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/core": "^
|
|
48
|
-
"@babel/preset-env": "^
|
|
49
|
-
"babel-jest": "^30.2
|
|
50
|
-
"jest": "^30.2
|
|
51
|
-
"jest-environment-jsdom": "^30.2
|
|
47
|
+
"@babel/core": "^8.0.7",
|
|
48
|
+
"@babel/preset-env": "^8.0.7",
|
|
49
|
+
"babel-jest": "^30.5.2",
|
|
50
|
+
"jest": "^30.5.2",
|
|
51
|
+
"jest-environment-jsdom": "^30.5.2",
|
|
52
52
|
"shelljs": "^0.10.0",
|
|
53
53
|
"shx": "^0.4.0"
|
|
54
54
|
}
|