Skip to content

Commit 8703827

Browse files
author
Dave Conway-Jones
committed
fix script injection to notification - bump to 2.17.0
1 parent a7ecb4b commit 8703827

File tree

7 files changed

+25
-12
lines changed

7 files changed

+25
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
### 2.16.4-beta: Maintenance Release
2-
3-
**Enhancements**
1+
### 2.17.0: Maintenance Release
42

53
**Fixes**
64

75
- Better vertical align larger button icons if supplied via label text
6+
- Fix ui_notification node to not accept raw HTML by default, add option to allow.
87

98
### 2.16.3: Maintenance Release
109

dist/dashboard.appcache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ fonts/weather-icons-lite.woff2
2424
NETWORK:
2525
*
2626

27-
# hash: c50d6ccb3895b8cbd2a6114acbc93dc3c9c6f359018907aa8f609ffef066c498
27+
# hash: a27822f01b29538a854757969a42c6d6d898aab36f354980c53870c2058e5f60

dist/js/app.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodes/ui_toast.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
outputs: {value: 0},
1111
ok: {value: 'OK', required: true},
1212
cancel: {value: ''},
13+
raw: {value: false},
1314
topic: {value: ''},
1415
name: {value: ''}
1516
},
@@ -67,7 +68,7 @@
6768
<input type="text" id="node-input-highlight" placeholder="(optional) border highlight colour">
6869
</div>
6970
<div class="form-row" id="node-toast-sendtoall">
70-
<label style="width:auto" for="node-input-sendall"><i class="fa fa-arrow-right"></i> Send to all browser sessions.</label>
71+
<label style="width:auto" for="node-input-sendall"><i class="fa fa-arrow-right"></i> Send to all browser sessions. </label>
7172
<input type="checkbox" checked id="node-input-sendall" style="display:inline-block; width:auto; vertical-align:baseline;">
7273
</div>
7374
<div class="form-row" id="node-dialog-displayok">
@@ -78,6 +79,10 @@
7879
<label for="node-input-cancel"><i class="fa fa-times"></i> Secondary action label</label>
7980
<input type="text" id="node-input-cancel" placeholder="(optional label for Cancel button)">
8081
</div>
82+
<div class="form-row" id="node-toast-raw">
83+
<label style="width:auto" for="node-input-raw"><i class="fa fa-exclamation-triangle"></i> Accept raw HTML/JavaScript input. </label>
84+
<input type="checkbox" id="node-input-raw" style="display:inline-block; width:auto; vertical-align:baseline;">
85+
</div>
8186
<div class="form-row" id="node-dialog-topic">
8287
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
8388
<input type="text" id="node-input-topic" placeholder="(optional msg.topic)">
@@ -86,6 +91,8 @@
8691
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
8792
<input type="text" id="node-input-name" placeholder="Name">
8893
</div>
94+
<div class="form-tips"><b>Note</b>: checking <i>Accept raw HTML/JavaScript</i> can allow injection of code.
95+
Ensure the input comes from trusted sources.</span></div>
8996
</script>
9097

9198
<script type="text/x-red" data-help-name="ui_toast">

nodes/ui_toast.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ module.exports = function(RED) {
1616
this.topic = config.topic;
1717
if (config.sendall === undefined) { this.sendall = true; }
1818
else { this.sendall = config.sendall; }
19+
this.raw = config.raw || false;
1920
var node = this;
2021

2122
var noscript = function (content) {
2223
if (typeof content === "object") { return null; }
2324
content = '' + content;
24-
content = content.replace(/<.*cript.*\/scrip.*>/ig, '');
25-
content = content.replace(/ on\w+=".*"/g, '');
26-
content = content.replace(/ on\w+=\'.*\'/g, '');
25+
content = content.replace(/<.*cript.*/ig, '');
26+
content = content.replace(/.on\w+=.*".*"/g, '');
27+
content = content.replace(/.on\w+=.*\'.*\'/g, '');
2728
return content;
2829
}
2930

@@ -41,7 +42,7 @@ module.exports = function(RED) {
4142

4243
node.on('input', function(msg) {
4344
if (node.position !== "dialog" && node.sendall === true) { delete msg.socketid; }
44-
msg.payload = noscript(msg.payload);
45+
//msg.payload = noscript(msg.payload);
4546
ui.emitSocket('show-toast', {
4647
title: node.topic || msg.topic,
4748
message: msg.payload,
@@ -53,6 +54,7 @@ module.exports = function(RED) {
5354
ok: node.ok,
5455
cancel: node.cancel,
5556
socketid: msg.socketid,
57+
raw: node.raw,
5658
msg: msg
5759
});
5860
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-dashboard",
3-
"version": "2.16.4-beta",
3+
"version": "2.17.0",
44
"description": "A set of dashboard nodes for Node-RED",
55
"keywords": [
66
"node-red"

src/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,11 @@ app.controller('MainController', ['$mdSidenav', '$window', 'UiEvents', '$locatio
511511
});
512512

513513
events.on('show-toast', function (msg) {
514+
if (msg.raw !== true) {
515+
var temp = document.createElement('div');
516+
temp.textContent = str;
517+
msg.message = temp.innerHTML;
518+
}
514519
if (msg.dialog === true) {
515520
var confirm;
516521
if (msg.cancel) {

0 commit comments

Comments
 (0)