Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Commit 6aae877

Browse files
committed
💥 '); DROP TABLES 'commits' -- __injectCSS(); //
1 parent ea199bd commit 6aae877

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

src/_renderer.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
window.eval = global.eval = function () {
33
throw new Error("eval() is disabled for security reasons.");
44
};
5+
// Security helper :)
6+
window._escapeHtml = (text) => {
7+
let map = {
8+
'&': '&',
9+
'<': '&lt;',
10+
'>': '&gt;',
11+
'"': '&quot;',
12+
"'": '&#039;'
13+
};
14+
return text.replace(/[&<>"']/g, m => {return map[m];});
15+
};
16+
window._purifyCSS = (str) => {
17+
let map = {
18+
'<': '&lt;',
19+
'>': '&gt;'
20+
};
21+
return str.replace(/[&<>"']/g, m => {return map[m];});
22+
};
523

624
// Initiate basic error handling
725
window.onerror = (msg, path, line, col, error) => {
@@ -56,6 +74,8 @@ window._loadTheme = (theme) => {
5674
body {
5775
font-family: var(--font_main), sans-serif;
5876
}
77+
78+
${window._purifyCSS(theme.injectCSS || "")}
5979
</style>`;
6080

6181
window.theme = theme;

src/classes/filesystem.class.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,25 @@ class FilesystemDisplay {
107107

108108
this._tmp.dirs.forEach(e => {
109109
this.cwd.push({
110-
name: this._escapeHtml(e),
110+
name: window._escapeHtml(e),
111111
type: "dir"
112112
});
113113
});
114114
this._tmp.symlinks.forEach(e => {
115115
this.cwd.push({
116-
name: this._escapeHtml(e),
116+
name: window._escapeHtml(e),
117117
type: "symlink"
118118
});
119119
});
120120
this._tmp.files.forEach(e => {
121121
if (tcwd === themesDir && e.endsWith(".json")) {
122122
this.cwd.push({
123-
name: this._escapeHtml(e),
123+
name: window._escapeHtml(e),
124124
type: "edex-theme"
125125
});
126126
} else {
127127
this.cwd.push({
128-
name: this._escapeHtml(e),
128+
name: window._escapeHtml(e),
129129
type: "file"
130130
});
131131
}
@@ -204,14 +204,4 @@ class FilesystemDisplay {
204204
this.space_bar.bar.value = Math.round(this.fsBlock.use);
205205
};
206206
}
207-
_escapeHtml(text) {
208-
let map = {
209-
'&': '&amp;',
210-
'<': '&lt;',
211-
'>': '&gt;',
212-
'"': '&quot;',
213-
"'": '&#039;'
214-
};
215-
return text.replace(/[&<>"']/g, m => {return map[m];});
216-
}
217207
}

src/ui.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5-
<meta http-equiv="Content-Security-Policy" content="default-src file: 'unsafe-inline'; connect-src ws:">
5+
<meta http-equiv="Content-Security-Policy" content="default-src file: 'unsafe-inline'; img-src data:; connect-src ws:">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>eDEX-UI</title>
88

0 commit comments

Comments
 (0)