Merge pull request #5974 from xtermjs/cursor/parser-validation-fixes-89d6

fix(parser): Params error grammar and ESC prefix precedence
This commit is contained in:
Daniel Imms
2026-06-01 09:05:28 -07:00
committed by GitHub
5 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ function identifier(id: IFunctionIdentifier): number {
throw new Error('only one byte as prefix supported');
}
res = id.prefix.charCodeAt(0);
if (res && 0x3c > res || res > 0x3f) {
if (res < 0x3c || res > 0x3f) {
throw new Error('prefix must be in range 0x3c .. 0x3f');
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ function identifier(id: IFunctionIdentifier): number {
throw new Error('only one byte as prefix supported');
}
res = id.prefix.charCodeAt(0);
if (res && 0x3c > res || res > 0x3f) {
if (res < 0x3c || res > 0x3f) {
throw new Error('prefix must be in range 0x3c .. 0x3f');
}
}
+1 -1
View File
@@ -342,7 +342,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
throw new Error('only one byte as prefix supported');
}
res = id.prefix.charCodeAt(0);
if (res && 0x3c > res || res > 0x3f) {
if (res < 0x3c || res > 0x3f) {
throw new Error('prefix must be in range 0x3c .. 0x3f');
}
}
+2 -2
View File
@@ -199,13 +199,13 @@ describe('Params', () => {
it('reject params lesser -1', () => {
const params = new Params();
params.addParam(-1);
assert.throws(() => params.addParam(-2), 'values lesser than -1 are not allowed');
assert.throws(() => params.addParam(-2), 'values less than -1 are not allowed');
});
it('reject subparams lesser -1', () => {
const params = new Params();
params.addParam(-1);
params.addSubParam(-1);
assert.throws(() => params.addSubParam(-2), 'values lesser than -1 are not allowed');
assert.throws(() => params.addSubParam(-2), 'values less than -1 are not allowed');
assert.deepEqual(params.toArray(), [-1, [-1]]);
});
it('clamp parsed params', () => {
+2 -2
View File
@@ -162,7 +162,7 @@ export class Params implements IParams {
return;
}
if (value < -1) {
throw new Error('values lesser than -1 are not allowed');
throw new Error('values less than -1 are not allowed');
}
this._subParamsIdx[this.length] = this._subParamsLength << 8 | this._subParamsLength;
this.params[this.length++] = value > Constants.MAX_VALUE ? Constants.MAX_VALUE : value;
@@ -185,7 +185,7 @@ export class Params implements IParams {
return;
}
if (value < -1) {
throw new Error('values lesser than -1 are not allowed');
throw new Error('values less than -1 are not allowed');
}
this._subParams[this._subParamsLength++] = value > Constants.MAX_VALUE ? Constants.MAX_VALUE : value;
this._subParamsIdx[this.length - 1]++;