dsh-unlag 1.7.5 → 1.7.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.
- package/client.js +26 -0
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -115,6 +115,7 @@ window.__ModuleLoader__.load({
|
|
|
115
115
|
for (const id of source.ids) {
|
|
116
116
|
if (!body.includes(id)) return false;
|
|
117
117
|
}
|
|
118
|
+
if (!parsesAsClassicScript(body)) return false;
|
|
118
119
|
} catch {
|
|
119
120
|
return false;
|
|
120
121
|
}
|
|
@@ -122,6 +123,28 @@ window.__ModuleLoader__.load({
|
|
|
122
123
|
return true;
|
|
123
124
|
}
|
|
124
125
|
|
|
126
|
+
// Every row kind a document boot understands; an unknown one ends the document.
|
|
127
|
+
const STARTUP_ROW_KINDS = new Set(['global', 'script', 'script-src', 'script-preload', 'style', 'html']);
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Whether a script body parses the way the document will parse it: as a classic script. A body
|
|
131
|
+
* that needs module syntax never runs, so the document that loads it fails to boot and the
|
|
132
|
+
* desktop shell ends. Compiling runs nothing, so nothing here has a side effect; a page that
|
|
133
|
+
* forbids compiling strings cannot answer, and then the checks already done stand.
|
|
134
|
+
* @param body - the served script.
|
|
135
|
+
* @returns true when the body parses, or when this page cannot compile one at all.
|
|
136
|
+
*/
|
|
137
|
+
function parsesAsClassicScript(body) {
|
|
138
|
+
try {
|
|
139
|
+
new Function(body); // eslint-disable-line no-new-func
|
|
140
|
+
return true;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
const text = String(error?.message ?? error);
|
|
143
|
+
if (/unsafe-eval|Content Security Policy/iu.test(text)) return true;
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
125
148
|
/**
|
|
126
149
|
* The startup list the desktop shell hands the next document, exactly as it hands it. The
|
|
127
150
|
* shell reads that list once when the app starts and replays the same copy for every document
|
|
@@ -153,6 +176,8 @@ window.__ModuleLoader__.load({
|
|
|
153
176
|
let frozen = null;
|
|
154
177
|
for (const row of rows) {
|
|
155
178
|
if (row === null || typeof row !== 'object') continue;
|
|
179
|
+
if (typeof row.kind !== 'string' || !STARTUP_ROW_KINDS.has(row.kind)) return false;
|
|
180
|
+
if (row.kind === 'script-src' && (typeof row.src !== 'string' || row.src === '')) return false;
|
|
156
181
|
if (typeof row.src === 'string' && row.src !== '') scripts.push(row.src);
|
|
157
182
|
if (row.kind !== 'global' || row.name !== '__DSH_BOOT__') continue; // ui-copy-ignore
|
|
158
183
|
let value = row.value;
|
|
@@ -190,6 +215,7 @@ window.__ModuleLoader__.load({
|
|
|
190
215
|
for (const id of bundledIds(target)) {
|
|
191
216
|
if (!body.includes(id)) return false;
|
|
192
217
|
}
|
|
218
|
+
if (!parsesAsClassicScript(body)) return false;
|
|
193
219
|
} catch {
|
|
194
220
|
return false;
|
|
195
221
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-unlag",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "One press applies plugin edits right away and brings a laggy interface back; running turns, queued messages and unsent input are untouched, and nothing restarts.",
|
|
6
6
|
"license": "MIT",
|