Explorar o código

Use textContent instead of innerHTML

Previously, setting `innerHTML` was used to display the statuses.  These
could include content communicated from the remote VNC server, allowing
the remove VNC server to inject HTML into the noVNC page.

This commit switches all uses of `innerHTML` to use `textContent`, which
is not vulnerable to the HTML injection.
Solly Ross %!s(int64=8) %!d(string=hai) anos
pai
achega
15ce2f71eb
Modificáronse 10 ficheiros con 14 adicións e 14 borrados
  1. 3 3
      include/ui.js
  2. 1 1
      tests/arrays.js
  3. 1 1
      tests/base64.html
  4. 1 1
      tests/canvas.html
  5. 1 1
      tests/cursor.html
  6. 1 1
      tests/input.html
  7. 1 1
      tests/viewport.html
  8. 2 2
      tests/vnc_perf.html
  9. 2 2
      tests/vnc_playback.html
  10. 1 1
      vnc_auto.html

+ 3 - 3
include/ui.js

@@ -285,7 +285,7 @@ var UI;
 
             if (typeof(msg) !== 'undefined') {
                 $D('noVNC_control_bar').setAttribute("class", klass);
-                $D('noVNC_status').innerHTML = msg;
+                $D('noVNC_status').textContent = msg;
             }
 
             UI.updateVisualState();
@@ -360,9 +360,9 @@ var UI;
             clearTimeout(UI.popupStatusTimeout);
 
             if (typeof text === 'string') {
-                psp.innerHTML = text;
+                psp.textContent = text;
             } else {
-                psp.innerHTML = $D('noVNC_status').innerHTML;
+                psp.textContent = $D('noVNC_status').textContent;
             }
             psp.style.display = "block";
             psp.style.left = window.innerWidth/2 -

+ 1 - 1
tests/arrays.js

@@ -36,7 +36,7 @@ if (Util.Engine.trident) {
 function message(str) {
     //console.log(str);
     cell = $D('messages');
-    cell.innerHTML += str + newline;
+    cell.textContent += str + newline;
     cell.scrollTop = cell.scrollHeight;
 }
 

+ 1 - 1
tests/base64.html

@@ -20,7 +20,7 @@
     function debug(str) {
         console.log(str);
         cell = $D('debug');
-        cell.innerHTML += str + "\n";
+        cell.textContent += str + "\n";
         cell.scrollTop = cell.scrollHeight;
     }
 

+ 1 - 1
tests/canvas.html

@@ -42,7 +42,7 @@
         function message(str) {
             console.log(str);
             cell = $D('messages');
-            cell.innerHTML += msg_cnt + ": " + str + "\n";
+            cell.textContent += msg_cnt + ": " + str + "\n";
             cell.scrollTop = cell.scrollHeight;
             msg_cnt += 1;
         }

+ 1 - 1
tests/cursor.html

@@ -35,7 +35,7 @@
     function debug(str) {
         console.log(str);
         cell = $D('debug');
-        cell.innerHTML += str + "\n";
+        cell.textContent += str + "\n";
         cell.scrollTop = cell.scrollHeight;
     }
 

+ 1 - 1
tests/input.html

@@ -44,7 +44,7 @@
         function message(str) {
             console.log(str);
             cell = $D('messages');
-            cell.innerHTML += msg_cnt + ": " + str + newline;
+            cell.textContent += msg_cnt + ": " + str + newline;
             cell.scrollTop = cell.scrollHeight;
             msg_cnt++;
         }

+ 1 - 1
tests/viewport.html

@@ -56,7 +56,7 @@
         function message(str) {
             console.log(str);
             cell = $D('messages');
-            cell.innerHTML += msg_cnt + ": " + str + newline;
+            cell.textContent += msg_cnt + ": " + str + newline;
             cell.scrollTop = cell.scrollHeight;
             msg_cnt++;
         }

+ 2 - 2
tests/vnc_perf.html

@@ -64,7 +64,7 @@
         function msg(str) {
             console.log(str);
             var cell = $D('messages');
-            cell.innerHTML += str + "\n";
+            cell.textContent += str + "\n";
             cell.scrollTop = cell.scrollHeight;
         }
         function dbgmsg(str) {
@@ -88,7 +88,7 @@
                     break;
             }
             if (typeof mesg !== 'undefined') {
-                $D('VNC_status').innerHTML = mesg;
+                $D('VNC_status').textContent = mesg;
             }
         }
 

+ 2 - 2
tests/vnc_playback.html

@@ -51,7 +51,7 @@
         function message(str) {
             console.log(str);
             var cell = $D('messages');
-            cell.innerHTML += str + "\n";
+            cell.textContent += str + "\n";
             cell.scrollTop = cell.scrollHeight;
         }
 
@@ -78,7 +78,7 @@
                     break;
             }
             if (typeof msg !== 'undefined') {
-                $D('VNC_status').innerHTML = msg;
+                $D('VNC_status').textContent = msg;
             }
         }
 

+ 1 - 1
vnc_auto.html

@@ -152,7 +152,7 @@
 
             if (typeof(msg) !== 'undefined') {
                 sb.setAttribute("class", "noVNC_status_" + level);
-                s.innerHTML = msg;
+                s.textContent = msg;
             }
         }