Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/cli/src/utils/terminalSequence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ describe('parseAllowedTerminalSequences', () => {
it('rejects OSC with no numeric code', () => {
expect(parseAllowedTerminalSequences('\x1b];hello\x07')).toBeNull();
});

it('rejects OSC when the code is not followed by a separator', () => {
expect(parseAllowedTerminalSequences('\x1b]9oops\x07')).toBeNull();
expect(parseAllowedTerminalSequences('\x1b]9\x07')).toBeNull();
expect(parseAllowedTerminalSequences('\x1b]9\x1b\\')).toBeNull();
});
});
});

Expand Down
5 changes: 2 additions & 3 deletions packages/cli/src/utils/terminalSequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ function parseOscSequence(input: string, start: number): OscParseResult | null {
const oscCode = Number(codeStr);
if (!ALLOWED_OSC_CODES.has(oscCode)) return null;

// After the code, expect ';' or a terminator
// (OSC 0/1/2 can have just a title with ';')
if (position >= input.length) return null;
// After the code, require ';' before the payload.
if (position >= input.length || input[position] !== ';') return null;

// Read until terminator: BEL or ST (ESC \)
// The ';' after code is part of payload
Expand Down
Loading