Skip to content

Commit

Permalink
fix handling slashes + ignore broken ANSI escapes #460
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jan 19, 2019
1 parent d599cbd commit 00ba172
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 41 deletions.
15 changes: 3 additions & 12 deletions js/jquery.terminal-2.0.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* emoji regex v7.0.1 by Mathias Bynens
* MIT license
*
* Date: Sat, 19 Jan 2019 10:17:34 +0000
* Date: Sat, 19 Jan 2019 10:43:55 +0000
*/

/* TODO:
Expand Down Expand Up @@ -3471,7 +3471,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sat, 19 Jan 2019 10:17:34 +0000',
date: 'Sat, 19 Jan 2019 10:43:55 +0000',
// colors from http://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -4205,16 +4205,7 @@
// ---------------------------------------------------------------------
format: function format(str, options) {
function safe_text(string) {
if (string.match(/\\]/)) {
string = string.replace(/(\\+)]/g, function(_, slashes) {
if (slashes.length % 2 === 1) {
return ']';
} else {
return slashes.replace(/../, '\\');
}
});
}
return safe(string);
return safe(string.replace(/\\\\/g, '\\'));
}
var settings = $.extend({}, {
linksNoReferrer: false,
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.0.2.min.js

Large diffs are not rendered by default.

11 changes: 1 addition & 10 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -4205,16 +4205,7 @@
// ---------------------------------------------------------------------
format: function format(str, options) {
function safe_text(string) {
if (string.match(/\\]/)) {
string = string.replace(/(\\+)]/g, function(_, slashes) {
if (slashes.length % 2 === 1) {
return ']';
} else {
return slashes.replace(/../, '\\');
}
});
}
return safe(string);
return safe(string.replace(/\\\\/g, '\\'));
}
var settings = $.extend({}, {
linksNoReferrer: false,
Expand Down
15 changes: 3 additions & 12 deletions js/jquery.terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* emoji regex v7.0.1 by Mathias Bynens
* MIT license
*
* Date: Sat, 19 Jan 2019 10:17:34 +0000
* Date: Sat, 19 Jan 2019 10:43:55 +0000
*/

/* TODO:
Expand Down Expand Up @@ -3471,7 +3471,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sat, 19 Jan 2019 10:17:34 +0000',
date: 'Sat, 19 Jan 2019 10:43:55 +0000',
// colors from http://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -4205,16 +4205,7 @@
// ---------------------------------------------------------------------
format: function format(str, options) {
function safe_text(string) {
if (string.match(/\\]/)) {
string = string.replace(/(\\+)]/g, function(_, slashes) {
if (slashes.length % 2 === 1) {
return ']';
} else {
return slashes.replace(/../, '\\');
}
});
}
return safe(string);
return safe(string.replace(/\\\\/g, '\\'));
}
var settings = $.extend({}, {
linksNoReferrer: false,
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/jquery.terminal.min.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions js/unix_formatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,11 @@
break;
}
} else if (splitted[i] !== '') {
var text = splitted[i].replace(/\x1b\[[0-9;]*/g, '');
if (settings.unixFormattingEscapeBrackets) {
output.push($.terminal.escape_formatting(splitted[i]));
output.push($.terminal.escape_formatting(text));
} else {
output.push(splitted[i]);
output.push(text);
}
}
} // for
Expand Down

0 comments on commit 00ba172

Please sign in to comment.