web-manager 4.1.34 → 4.1.36

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/CHANGELOG.md CHANGED
@@ -14,6 +14,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
14
14
  - `Fixed` for any bug fixes.
15
15
  - `Security` in case of vulnerabilities.
16
16
 
17
+ ---
18
+ ## [4.1.36] - 2026-04-02
19
+ ### Fixed
20
+ - Fixed mocha binary path preventing `npm test` from running.
21
+ - Fixed lodash ESM named import incompatibility with Node.js (`storage.js`).
22
+ - Fixed test suite calling nonexistent API methods (`init` → `initialize`, `storage('local')` → `storage()`).
23
+ - Fixed mocha hanging after tests due to `setInterval` in version checker (added `--exit` flag).
24
+
25
+ ### Changed
26
+ - Enhanced `escapeHTML` to recursively handle objects, arrays, and pass through non-string types.
27
+ - Rewrote `showNotification` to use safe DOM construction (`textContent`) instead of `innerHTML`.
28
+ - Split monolithic `test.js` into 8 modular test files under `test/tests/`.
29
+ - Expanded test coverage from ~10 broken tests to 70 passing tests.
30
+
31
+ ### Security
32
+ - Blocked `javascript:` protocol in `@attr` bindings for URL attributes (`href`, `src`, `action`, `formaction`).
33
+
34
+ ---
35
+ ## [4.1.35] - 2026-04-02
36
+ ### Changed
37
+ - Bumped `chatsy` from `^2.0.13` to `^2.0.14`.
38
+
17
39
  ---
18
40
  ## [4.1.34] - 2026-04-01
19
41
  ### Changed
@@ -150,6 +150,14 @@ class Bindings {
150
150
  const attrValue = this._resolvePath(context, attrExpression) || '';
151
151
 
152
152
  if (attrValue) {
153
+ // Block javascript: protocol on URL attributes to prevent XSS
154
+ const URL_ATTRS = ['href', 'src', 'action', 'formaction'];
155
+ if (URL_ATTRS.includes(attrName.toLowerCase())
156
+ && /^\s*javascript\s*:/i.test(String(attrValue))) {
157
+ console.warn(`[Bindings] Blocked javascript: URL in @attr ${attrName}`);
158
+ return true;
159
+ }
160
+
153
161
  element.setAttribute(attrName, attrValue);
154
162
  } else {
155
163
  element.removeAttribute(attrName);
@@ -1,4 +1,5 @@
1
- import { get as _get, set as _set } from 'lodash';
1
+ import lodash from 'lodash';
2
+ const { get: _get, set: _set } = lodash;
2
3
 
3
4
  class Storage {
4
5
  constructor() {
@@ -37,26 +37,48 @@ class Utilities {
37
37
  }
38
38
 
39
39
  // Escape HTML to prevent XSS
40
- escapeHTML(str) {
41
- if (typeof str !== 'string') {
42
- return '';
40
+ // Accepts a string, object, or array — walks recursively, escaping all string values
41
+ escapeHTML(input) {
42
+ // Strings — escape and return
43
+ if (typeof input === 'string') {
44
+ this._shadowElement = this._shadowElement || document.createElement('p');
45
+ this._shadowElement.innerHTML = '';
46
+
47
+ // This automatically escapes HTML entities like <, >, &, etc.
48
+ this._shadowElement.appendChild(document.createTextNode(input));
49
+
50
+ // This is needed to escape quotes to prevent attribute injection
51
+ return this._shadowElement.innerHTML.replace(/["']/g, (m) => {
52
+ switch (m) {
53
+ case '"':
54
+ return '&quot;';
55
+ default:
56
+ return '&#039;';
57
+ }
58
+ });
43
59
  }
44
60
 
45
- this._shadowElement = this._shadowElement || document.createElement('p');
46
- this._shadowElement.innerHTML = '';
61
+ // Null/undefined pass through
62
+ if (input == null) {
63
+ return input;
64
+ }
47
65
 
48
- // This automatically escapes HTML entities like <, >, &, etc.
49
- this._shadowElement.appendChild(document.createTextNode(str));
66
+ // Arrays recurse each item
67
+ if (Array.isArray(input)) {
68
+ return input.map(item => this.escapeHTML(item));
69
+ }
50
70
 
51
- // This is needed to escape quotes to prevent attribute injection
52
- return this._shadowElement.innerHTML.replace(/["']/g, (m) => {
53
- switch (m) {
54
- case '"':
55
- return '&quot;';
56
- default:
57
- return '&#039;';
71
+ // Objects shallow clone, recurse each value
72
+ if (typeof input === 'object') {
73
+ const result = {};
74
+ for (const [key, value] of Object.entries(input)) {
75
+ result[key] = this.escapeHTML(value);
58
76
  }
59
- });
77
+ return result;
78
+ }
79
+
80
+ // Numbers, booleans, etc. — pass through unchanged
81
+ return input;
60
82
  }
61
83
 
62
84
  // Show notification
@@ -83,10 +105,17 @@ class Utilities {
83
105
  const $notification = document.createElement('div');
84
106
  $notification.className = `alert alert-${type} alert-dismissible fade show position-fixed`;
85
107
  $notification.style.cssText = 'z-index: 9999; top: 1rem; left: 50%; transform: translateX(-50%);';
86
- $notification.innerHTML = `
87
- ${text}
88
- <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
89
- `;
108
+
109
+ const $text = document.createElement('span');
110
+ $text.textContent = text;
111
+
112
+ const $closeBtn = document.createElement('button');
113
+ $closeBtn.type = 'button';
114
+ $closeBtn.className = 'btn-close';
115
+ $closeBtn.setAttribute('data-bs-dismiss', 'alert');
116
+
117
+ $notification.appendChild($text);
118
+ $notification.appendChild($closeBtn);
90
119
 
91
120
  document.body.appendChild($notification);
92
121
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "4.1.34",
3
+ "version": "4.1.36",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
@@ -11,8 +11,7 @@
11
11
  },
12
12
  "scripts": {
13
13
  "start": "npm run prepare:watch",
14
- "test": "./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
15
- "test_": "npm run prepare && ./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
14
+ "test": "npm run prepare && mocha --require ./test/setup.js --require ./test/helpers.js 'test/tests/**/*.test.js' --timeout=10000 --exit",
16
15
  "prepare_": "node -e 'require(`prepare-package`)()'",
17
16
  "prepare": "node -e \"require('prepare-package')()\"",
18
17
  "prepare:watch": "node -e \"require('prepare-package/watch')()\""
@@ -44,7 +43,7 @@
44
43
  },
45
44
  "dependencies": {
46
45
  "@sentry/browser": "^10.47.0",
47
- "chatsy": "^2.0.13",
46
+ "chatsy": "^2.0.14",
48
47
  "firebase": "^12.11.0",
49
48
  "itwcw-package-analytics": "^1.0.8",
50
49
  "lodash": "^4.18.1"