Skip to content

Commit e2b5ec1

Browse files
committed
more defensive coding for these handlers
1 parent 7608afc commit e2b5ec1

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

frontend/app/view/term/termwrap.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,34 @@ export class TermWrap {
174174
this.setTermRenderer(WebGLSupported && waveOptions.useWebGl ? "webgl" : "dom");
175175
// Register OSC handlers
176176
this.terminal.parser.registerOscHandler(7, (data: string) => {
177-
return handleOsc7Command(data, this.blockId, this.loaded);
177+
try {
178+
return handleOsc7Command(data, this.blockId, this.loaded);
179+
} catch (e) {
180+
console.error("[termwrap] osc 7 handler error", this.blockId, e);
181+
return false;
182+
}
178183
});
179184
this.terminal.parser.registerOscHandler(52, (data: string) => {
180-
return handleOsc52Command(data, this.blockId, this.loaded, this);
185+
try {
186+
return handleOsc52Command(data, this.blockId, this.loaded, this);
187+
} catch (e) {
188+
console.error("[termwrap] osc 52 handler error", this.blockId, e);
189+
return false;
190+
}
181191
});
182192
this.terminal.parser.registerOscHandler(16162, (data: string) => {
183-
return handleOsc16162Command(data, this.blockId, this.loaded, this);
193+
try {
194+
return handleOsc16162Command(data, this.blockId, this.loaded, this);
195+
} catch (e) {
196+
console.error("[termwrap] osc 16162 handler error", this.blockId, e);
197+
return false;
198+
}
184199
});
185200
this.toDispose.push(
186201
this.terminal.parser.registerCsiHandler({ final: "J" }, (params) => {
202+
if (params == null || params.length < 1) {
203+
return false;
204+
}
187205
if (params[0] === 3) {
188206
this.lastClearScrollbackTs = Date.now();
189207
if (this.inSyncTransaction) {
@@ -196,6 +214,9 @@ export class TermWrap {
196214
);
197215
this.toDispose.push(
198216
this.terminal.parser.registerCsiHandler({ prefix: "?", final: "h" }, (params) => {
217+
if (params == null || params.length < 1) {
218+
return false;
219+
}
199220
if (params[0] === 2026) {
200221
this.lastMode2026SetTs = Date.now();
201222
this.inSyncTransaction = true;
@@ -205,6 +226,9 @@ export class TermWrap {
205226
);
206227
this.toDispose.push(
207228
this.terminal.parser.registerCsiHandler({ prefix: "?", final: "l" }, (params) => {
229+
if (params == null || params.length < 1) {
230+
return false;
231+
}
208232
if (params[0] === 2026) {
209233
this.lastMode2026ResetTs = Date.now();
210234
this.inSyncTransaction = false;

0 commit comments

Comments
 (0)