Skip to content

Commit be54a5a

Browse files
committed
refactor
1 parent 4c9cc1c commit be54a5a

File tree

8 files changed

+21
-20
lines changed

8 files changed

+21
-20
lines changed

services/static-webserver/client/source/class/osparc/auth/ui/RequestAccount.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ qx.Class.define("osparc.auth.ui.RequestAccount", {
197197
id: "Image_based_Modeling",
198198
label: "Image-based Modeling"
199199
}].forEach(appData => {
200-
const lItem = new qx.ui.form.ListItem(appData.label, null, appData.id);
200+
const lItem = new qx.ui.form.ListItem(appData.label, null, appData.id).set({
201+
rich: true
202+
});
201203
application.add(lItem);
202204
});
203205
doubleSpaced.push(application);

services/static-webserver/client/source/class/osparc/auth/ui/VerifyPhoneNumberView.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ qx.Class.define("osparc.auth.ui.VerifyPhoneNumberView", {
4545
control = new qx.ui.basic.Label().set({
4646
value: this.tr("Two-Factor Authentication (2FA)"),
4747
allowGrowX: true,
48+
rich: true,
4849
font: "text-16"
4950
});
5051
this.add(control);

services/static-webserver/client/source/class/osparc/dashboard/GroupedCardContainer.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,7 @@ qx.Class.define("osparc.dashboard.GroupedCardContainer", {
106106
rich: true,
107107
wrap: true
108108
});
109-
atomLabel.addListener("changeValue", e => {
110-
const val = e.getData();
111-
const sanitized = osparc.wrapper.DOMPurify.sanitize(val);
112-
if (sanitized !== val) {
113-
atomLabel.setValue(sanitized);
114-
}
115-
});
109+
osparc.wrapper.DOMPurify.sanitizeLabel(atomLabel);
116110
control.getContentElement().setStyles({
117111
"border-top-left-radius": "4px",
118112
"border-top-right-radius": "4px"

services/static-webserver/client/source/class/osparc/file/FolderContent.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,7 @@ qx.Class.define("osparc.file.FolderContent", {
7575
maxWidth: 100,
7676
maxHeight: 33 // two lines
7777
});
78-
toggleLabel.addListener("changeValue", e => {
79-
const val = e.getData();
80-
const sanitized = osparc.wrapper.DOMPurify.sanitize(val);
81-
if (sanitized !== val) {
82-
toggleLabel.setValue(sanitized);
83-
}
84-
});
78+
osparc.wrapper.DOMPurify.sanitizeLabel(toggleLabel);
8579
osparc.utils.Utils.setIdToWidget(item, "FolderViewerItem");
8680
return item;
8781
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
************************************************************************ */
1717

1818
/**
19-
* A Label that sanitizes its value when in rich mode to avoid XSS attacks
19+
* A Label that sanitizes its value to avoid XSS attacks
2020
*/
2121

2222
qx.Class.define("osparc.ui.basic.SafeLabel", {

services/static-webserver/client/source/class/osparc/ui/form/renderer/DoubleV.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,10 @@ qx.Class.define("osparc.ui.form.renderer.DoubleV", {
167167
* @param name {String} The content of the label without the
168168
* trailing * and :
169169
* @param item {qx.ui.core.Widget} The item, which has the required state.
170-
* @return {qx.ui.basic.Label} The label for the given item.
170+
* @return {osparc.ui.basic.SafeLabel} The label for the given item.
171171
*/
172172
_createLabel: function(name, item) {
173-
const label = new qx.ui.basic.Label(this._createLabelText(name, item)).set({
174-
rich: true,
175-
});
173+
const label = new osparc.ui.basic.SafeLabel(this._createLabelText(name, item));
176174
// store labels for disposal
177175
this._labels.push(label);
178176
return label;

services/static-webserver/client/source/class/osparc/workbench/NodeUI.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ qx.Class.define("osparc.workbench.NodeUI", {
7070

7171
const captionTitle = this.getChildControl("title");
7272
captionTitle.set({
73+
rich: true,
7374
cursor: "move"
7475
});
76+
osparc.wrapper.DOMPurify.sanitizeLabel(captionTitle);
7577

7678
this.__nodeMoving = false;
7779

services/static-webserver/client/source/class/osparc/wrapper/DOMPurify.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ qx.Class.define("osparc.wrapper.DOMPurify", {
4848
sanitize: function(html) {
4949
return osparc.wrapper.DOMPurify.getInstance().sanitize(html);
5050
},
51+
52+
sanitizeLabel: function(label) {
53+
label.addListener("changeValue", e => {
54+
const val = e.getData();
55+
const sanitized = osparc.wrapper.DOMPurify.sanitize(val);
56+
if (sanitized !== val) {
57+
label.setValue(sanitized);
58+
}
59+
});
60+
},
5161
},
5262

5363
construct: function() {

0 commit comments

Comments
 (0)