Skip to content

Commit

Permalink
Merge pull request #1783 from jerch/fix_1778
Browse files Browse the repository at this point in the history
fix minor parser issues:
- dont expose ESC+\ (7bit ST)
- add missing executables FS, GS, RS and US
  • Loading branch information
jerch committed Nov 9, 2018
2 parents 70981c7 + 4aa822e commit cb97ab3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/EscapeSequenceParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ describe('EscapeSequenceParser', function (): void {
parser.currentState = ParserState.ESCAPE_INTERMEDIATE;
parser.parse(collect[i]);
chai.expect(parser.currentState).equal(ParserState.GROUND);
testTerminal.compare([['esc', '', collect[i]]]);
// '\x5c' --> ESC + \ (7bit ST) parser does not expose this as it already got handled
testTerminal.compare((collect[i] === '\x5c') ? [] : [['esc', '', collect[i]]]);
parser.reset();
testTerminal.clear();
}
Expand Down Expand Up @@ -1051,6 +1052,13 @@ describe('EscapeSequenceParser', function (): void {
['csi', '<', [0, 0], 'c']
], null);
});
it('7bit ST should be swallowed', function(): void {
test('abc\x9d123tzf\x1b\\defg', [
['print', 'abc'],
['osc', '123tzf'],
['print', 'defg']
], null);
});
});
});

Expand Down Expand Up @@ -1089,7 +1097,7 @@ describe('EscapeSequenceParser', function (): void {
parser.reset();
testTerminal.clear();
parser.currentState = ParserState.GROUND;
parser.parse('\x1e');
parser.parse('\x9c');
chai.expect(parser.currentState).equal(ParserState.GROUND);
testTerminal.compare([]);
parser.reset();
Expand Down
5 changes: 4 additions & 1 deletion src/EscapeSequenceParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class TransitionTable {
const PRINTABLES = r(0x20, 0x7f);
const EXECUTABLES = r(0x00, 0x18);
EXECUTABLES.push(0x19);
EXECUTABLES.concat(r(0x1c, 0x20));
EXECUTABLES.push.apply(EXECUTABLES, r(0x1c, 0x20));
const DEFAULT_TRANSITION = ParserAction.ERROR << 4 | ParserState.GROUND;

/**
Expand Down Expand Up @@ -261,6 +261,9 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
this._dcsHandlers = Object.create(null);
this._activeDcsHandler = null;
this._errorHandler = this._errorHandlerFb;

// swallow 7bit ST (ESC+\)
this.setEscHandler('\\', () => {});
}

public dispose(): void {
Expand Down

0 comments on commit cb97ab3

Please sign in to comment.