Skip to content

Commit 46bae7f

Browse files
committed
shellIntegrationAddon: fix confusion of 'no match' and 'match at start of string'
deserializeMessage() would not recognize escape sequences at the start of a string, due to a simple falsey check on `match?.index` which could be validly 0 instead of null. In other words: "Foo\x3bBar" would decode to "Foo;Bar", but "\x3b" would not be recognized as an escape sequence. This fixes that bug, enabling those suppressed test cases, and disables the newly-failing tests which had only passed due to the (still-broken) escaping logic being skipped in those situations.
1 parent 83d4955 commit 46bae7f

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/vs/platform/terminal/common/xterm/shellIntegrationAddon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ export function deserializeMessage(message: string): string {
517517
const deserializeRegex = /\\x([0-9a-f]{2})/i;
518518
while (true) {
519519
const match = result.match(deserializeRegex);
520-
if (!match?.index || match.length < 2) {
520+
if (match?.index == null || match.length < 2) {
521521
break;
522522
}
523523
result = result.slice(0, match.index) + String.fromCharCode(parseInt(match[1], 16)) + result.slice(match.index + 4);

src/vs/workbench/contrib/terminal/test/browser/xterm/shellIntegrationAddon.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,9 @@ suite('deserializeMessage', () => {
288288
];
289289

290290
const BROKEN: readonly string[] = [
291-
'escaped semicolon',
292-
'escaped semicolon (upper hex)',
293-
// only "passing" due to interaction between two separate bugs:
294-
// 'escaped backslash followed by literal "x3b" is not a semicolon',
291+
'escaped backslash followed by literal "x3b" is not a semicolon',
295292
'non-initial escaped backslash followed by literal "x3b" is not a semicolon',
296-
'escaped newline',
297-
'escaped newline (upper hex)',
298-
// only "passing" due to interaction between two separate bugs:
299-
// 'escaped backslash followed by literal "x0a" is not a newline',
293+
'escaped backslash followed by literal "x0a" is not a newline',
300294
'non-initial escaped backslash followed by literal "x0a" is not a newline',
301295
];
302296

0 commit comments

Comments
 (0)