Skip to content

Commit e434511

Browse files
authored
Prevent innerHTML user input (#119)
1 parent 2e2fa41 commit e434511

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "openmct-mcws",
3-
"version": "5.2.0-rc1",
3+
"version": "5.2.0-rc2",
44
"description": "Open MCT for MCWS",
55
"devDependencies": {
6+
"@braintree/sanitize-url": "6.0.2",
67
"axios": "^0.21.2",
78
"babel-loader": "8.2.3",
89
"babel-plugin-istanbul": "6.1.1",
@@ -31,7 +32,7 @@
3132
"mini-css-extract-plugin": "2.6.0",
3233
"moment": "2.29.4",
3334
"node-bourbon": "^4.2.3",
34-
"openmct": "nasa/openmct#omm-r5.2.0-rc1",
35+
"openmct": "nasa/openmct#omm-r5.2.0-rc2",
3536
"openmct-legacy-support": "akhenry/openmct-legacy-support#omm-r5.1.0-rc1",
3637
"printj": "^1.2.1",
3738
"raw-loader": "^0.5.1",

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>gov.nasa.arc.wtd</groupId>
77
<artifactId>openmct-client</artifactId>
88
<name>Open MCT for MCWS Client</name>
9-
<version>5.2.0-rc1</version>
9+
<version>5.2.0-rc2</version>
1010
<packaging>war</packaging>
1111

1212
<properties>

src/identity/LoginService.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/*global define*/
22
define(
3-
[
4-
'./login.html'
5-
],
6-
function (loginTemplate) {
3+
[],
4+
function () {
75

86

97
/**
@@ -48,9 +46,13 @@ define(
4846
LoginService.prototype.show = function () {
4947
this.overlay = document.createElement('div');
5048
this.overlay.classList.add('u-contents');
51-
this.overlay.innerHTML = loginTemplate;
49+
50+
const iframe = document.createElement('iframe');
51+
iframe.classList.add('c-login-overlay');
52+
iframe.src = this.getLoginUrl();
53+
54+
this.overlay.appendChild(iframe);
5255
document.body.appendChild(this.overlay);
53-
this.overlay.querySelector('iframe').src = this.getLoginUrl();
5456
};
5557

5658
/**

src/identity/login.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/link/plugin.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
define([
2-
2+
'@braintree/sanitize-url'
33
], function (
4-
4+
urlSanitizeLib
55
) {
66

77
function LinkPlugin() {
@@ -32,7 +32,13 @@ define([
3232
view: function (domainObject) {
3333
return {
3434
show: function (container) {
35-
container.innerHTML = '<a href="' + domainObject.url + '">' + domainObject.name + '</a>'
35+
container.textContent = '';
36+
37+
const anchor = document.createElement('a');
38+
anchor.href = urlSanitizeLib.sanitizeUrl(domainObject.url);
39+
anchor.textContent = domainObject.name;
40+
41+
container.appendChild(anchor);
3642
},
3743
destroy: function () {}
3844
};

0 commit comments

Comments
 (0)