diff --git a/editor/js/ui/utils.js b/editor/js/ui/utils.js index 24227dd04..58af98b75 100644 --- a/editor/js/ui/utils.js +++ b/editor/js/ui/utils.js @@ -19,6 +19,9 @@ RED.utils = (function() { function formatString(str) { return str.replace(/\r?\n/g,"↵").replace(/\t/g,"→"); } + function sanitize(m) { + return m.replace(/&/g,"&").replace(//g,">"); + } function buildMessageSummaryValue(value) { var result; @@ -35,9 +38,11 @@ RED.utils = (function() { result = $('object'); } } else if (typeof value === 'string') { - subvalue = value; - if (subvalue.length > 30) { - subvalue = subvalue.substring(0,30)+"…"; + var subvalue; + if (value.length > 30) { + subvalue = sanitize(value.substring(0,30))+"…"; + } else { + subvalue = sanitize(value); } result = $('').html('"'+formatString(subvalue)+'"'); } else { @@ -68,7 +73,7 @@ RED.utils = (function() { var entryObj; var header; var headerHead; - var value,subvalue; + var value; var element = $(''); if (!key) { element.addClass("debug-message-top-level"); @@ -98,23 +103,26 @@ RED.utils = (function() { makeExpandable(header, function() { $('').html(typeHint||'string').appendTo(header); var row = $('').appendTo(element); - $('
').html(obj).appendTo(row);
+                    $('
').text(obj).appendTo(row);
                 });
             }
-            $('').html('"'+formatString(obj)+'"').appendTo(entryObj);
+            $('').html('"'+formatString(sanitize(obj))+'"').appendTo(entryObj);
 
 
         } else if (typeof obj === 'number') {
             e = $('').text(""+obj).appendTo(entryObj);
-            e.click(function(evt) {
-                var format = $(this).data('format');
-                if (format === 'hex') {
-                    $(this).text(""+obj).data('format','dec');
-                } else {
-                    $(this).text("0x"+(obj).toString(16)).data('format','hex');
-                }
-                evt.preventDefault();
-            });
+            if ((obj^0)===obj) {
+                e.addClass("debug-message-type-number-toggle");
+                e.click(function(evt) {
+                    var format = $(this).data('format');
+                    if (format === 'hex') {
+                        $(this).text(""+obj).data('format','dec');
+                    } else {
+                        $(this).text("0x"+(obj).toString(16)).data('format','hex');
+                    }
+                    evt.preventDefault();
+                });
+            }
         } else if (isArray) {
             element.addClass('collapsed');
 
@@ -155,7 +163,7 @@ RED.utils = (function() {
                         } catch(err) {
                             console.log(err);
                         }
-                        $('
').html(stringEncoding).appendTo(sr);
+                        $('
').text(stringEncoding).appendTo(sr);
                         var bufferOpts = $('').appendTo(headerHead);
                         $('').addClass('selected').html('raw').appendTo(bufferOpts).click(function(e) {
                             if ($(this).text() === 'raw') {
diff --git a/editor/sass/debug.scss b/editor/sass/debug.scss
index f56a8c7f3..7e3db9d10 100644
--- a/editor/sass/debug.scss
+++ b/editor/sass/debug.scss
@@ -150,7 +150,8 @@
 .debug-message-type-string { color: #b72828; }
 .debug-message-type-null { color: #666; font-style: italic;}
 .debug-message-type-meta { color: #666; font-style: italic;}
-.debug-message-type-number { color: #2033d6;cursor: pointer;}
+.debug-message-type-number { color: #2033d6; };
+.debug-message-type-number-toggle { cursor: pointer;}
 
 .debug-message-expandable {
     cursor: pointer;
diff --git a/nodes/core/core/lib/debug/debug-utils.js b/nodes/core/core/lib/debug/debug-utils.js
index 4767733a2..5322266a5 100644
--- a/nodes/core/core/lib/debug/debug-utils.js
+++ b/nodes/core/core/lib/debug/debug-utils.js
@@ -198,7 +198,7 @@ RED.debug = (function() {
         var name = sanitize(((o.name?o.name:o.id)||"").toString());
         var topic = sanitize((o.topic||"").toString());
         var property = sanitize(o.property?o.property:'');
-        var payload = sanitize((o.msg||"").toString());
+        var payload = o.msg;
         var format = sanitize((o.format||"").toString());
         msg.className = 'debug-message'+(o.level?(' debug-message-level-'+o.level):'') +
         ((sourceNode&&sourceNode.z)?((" debug-message-flow-"+sourceNode.z+((filter&&(activeWorkspace!==sourceNode.z))?" hide":""))):"");