diff --git a/src/octoprint/static/js/app/helpers.js b/src/octoprint/static/js/app/helpers.js index 744ce15b..d7248db6 100644 --- a/src/octoprint/static/js/app/helpers.js +++ b/src/octoprint/static/js/app/helpers.js @@ -1054,8 +1054,9 @@ var getQueryParameterByName = function(name, url) { * * E.g. turns a null byte in the string into "\x00". * - * Only characters 0 to 31, 127 and 255 will be escaped, that - * should leave printable characters and unicode alone. + * Characters 0 to 31 excluding 9, 10 and 13 will be escaped, as will + * 127 and 255. That should leave printable characters and unicode + * alone. * * Originally based on * https://gist.github.com/mathiasbynens/1243213#gistcomment-53590 @@ -1069,7 +1070,7 @@ var escapeUnprintableCharacters = function(str) { var charCode; while (!isNaN(charCode = str.charCodeAt(index))) { - if (charCode < 32 || charCode == 127 || charCode == 255) { + if ((charCode < 32 && charCode != 9 && charCode != 10 && charCode != 13) || charCode == 127 || charCode == 255) { // special hex chars result += "\\x" + (charCode > 15 ? "" : "0") + charCode.toString(16) } else {