Skip to content

Commit a7ec4de

Browse files
committed
SafeLabel
1 parent c9adfac commit a7ec4de

File tree

4 files changed

+49
-7
lines changed

4 files changed

+49
-7
lines changed

services/static-webserver/client/source/class/osparc/ui/basic/LinkLabel.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@
2929
*/
3030

3131
qx.Class.define("osparc.ui.basic.LinkLabel", {
32-
extend: qx.ui.basic.Label,
32+
extend: osparc.ui.basic.SafeLabel,
3333

3434
construct: function(label, url) {
3535
this.base(arguments, label);
3636

3737
this.set({
38-
rich: true,
3938
allowGrowX: true
4039
});
4140

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2025 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
/**
19+
* A Label that sanitizes its value when in rich mode to avoid XSS attacks
20+
*/
21+
22+
qx.Class.define("osparc.ui.basic.SafeLabel", {
23+
extend: qx.ui.basic.Label,
24+
25+
construct() {
26+
this.base(arguments);
27+
28+
this.set({
29+
rich: true,
30+
});
31+
32+
this.addListener("changeValue", this._onChangeValue, this);
33+
},
34+
35+
members: {
36+
_onChangeValue(e) {
37+
const val = e.getData();
38+
if (this.getRich() && typeof val === "string") {
39+
const sanitized = osparc.wrapper.DOMPurify.sanitize(val);
40+
if (sanitized !== val) {
41+
this.setValue(sanitized);
42+
}
43+
}
44+
}
45+
}
46+
});

services/static-webserver/client/source/class/osparc/ui/list/ListItem.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,19 @@ qx.Class.define("osparc.ui.list.ListItem", {
154154
});
155155
break;
156156
case "title":
157-
control = new qx.ui.basic.Label().set({
157+
control = new osparc.ui.basic.SafeLabel().set({
158158
font: "text-14",
159159
selectable: true,
160-
rich: true,
161160
});
162161
this._add(control, {
163162
row: 0,
164163
column: 1
165164
});
166165
break;
167166
case "subtitle":
168-
control = new qx.ui.basic.Label().set({
167+
control = new osparc.ui.basic.SafeLabel().set({
169168
font: "text-13",
170169
selectable: true,
171-
rich: true,
172170
});
173171
this._add(control, {
174172
row: 1,

services/static-webserver/client/source/class/osparc/widget/PreparingInputs.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ qx.Class.define("osparc.widget.PreparingInputs", {
2828
const text = this.tr("To proceed, we need to prepare some inputs. You can check the progress logs here:");
2929
const title = new qx.ui.basic.Label(text).set({
3030
font: "text-14",
31-
rich: true
3231
});
3332
this._add(title);
3433

0 commit comments

Comments
 (0)