Hex-escape unprintable characters in terminal tab
If there's any binary going over the line like null bytes, we want to see that here too.
This commit is contained in:
parent
e1eaf4eb8e
commit
7f0eb8d895
2 changed files with 34 additions and 1 deletions
|
|
@ -883,3 +883,36 @@ var getQueryParameterByName = function(name, url) {
|
|||
if (!results[2]) return '';
|
||||
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||
};
|
||||
|
||||
/**
|
||||
* Escapes unprintable ASCII characters in the provided string.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Originally based on
|
||||
* https://gist.github.com/mathiasbynens/1243213#gistcomment-53590
|
||||
*
|
||||
* @param str The string to escape
|
||||
* @returns {string}
|
||||
*/
|
||||
var escapeUnprintableCharacters = function(str) {
|
||||
var result = "";
|
||||
var index = 0;
|
||||
var charCode;
|
||||
|
||||
while (!isNaN(charCode = str.charCodeAt(index))) {
|
||||
if (charCode < 32 || charCode == 127 || charCode == 255) {
|
||||
// special hex chars
|
||||
result += "\\x" + (charCode > 15 ? "" : "0") + charCode.toString(16)
|
||||
} else {
|
||||
// anything else
|
||||
result += str[index];
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ $(function() {
|
|||
if (type == undefined) {
|
||||
type = "line";
|
||||
}
|
||||
return {line: line, type: type}
|
||||
return {line: escapeUnprintableCharacters(line), type: type}
|
||||
};
|
||||
|
||||
self._processStateData = function(data) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue