From 1a01e9634f694c9cf4d9898a75d67c418148af12 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sun, 31 May 2026 20:50:16 -0700 Subject: [PATCH 1/2] fix(parser): use correct grammar in Params validation errors Replace "values lesser than -1" with "values less than -1" in addParam and addSubParam throw messages. "Lesser" is not standard English for numeric comparisons; tests assert the exact message. Co-authored-by: Cursor --- src/common/parser/Params.test.ts | 4 ++-- src/common/parser/Params.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/parser/Params.test.ts b/src/common/parser/Params.test.ts index 3bd67d397..a30b1376c 100644 --- a/src/common/parser/Params.test.ts +++ b/src/common/parser/Params.test.ts @@ -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', () => { diff --git a/src/common/parser/Params.ts b/src/common/parser/Params.ts index 6986a48ba..9b6c3f855 100644 --- a/src/common/parser/Params.ts +++ b/src/common/parser/Params.ts @@ -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]++; From 4500485e7993d0956423356770fb777b9bf3ee2b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sun, 31 May 2026 21:52:33 -0700 Subject: [PATCH 2/2] fix(parser): validate ESC prefix byte range with correct precedence _identifier() checked custom prefix bytes with `res && 0x3c > res || res > 0x3f`, which parsed as `(res && 0x3c > res) || (res > 0x3f)` because && binds tighter than ||. A prefix of NUL (0x00) skipped both clauses and was accepted even though only 0x3c..0x3f are valid. Use an explicit range test: res < 0x3c || res > 0x3f. Mirror the same fix in ApcParser and DcsParser test identifier helpers. Co-authored-by: Cursor --- src/common/parser/ApcParser.test.ts | 2 +- src/common/parser/DcsParser.test.ts | 2 +- src/common/parser/EscapeSequenceParser.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/parser/ApcParser.test.ts b/src/common/parser/ApcParser.test.ts index b27b40039..563ddbeab 100644 --- a/src/common/parser/ApcParser.test.ts +++ b/src/common/parser/ApcParser.test.ts @@ -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'); } } diff --git a/src/common/parser/DcsParser.test.ts b/src/common/parser/DcsParser.test.ts index 459bc8961..5fa7b9416 100644 --- a/src/common/parser/DcsParser.test.ts +++ b/src/common/parser/DcsParser.test.ts @@ -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'); } } diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index a0c97b610..c12ca3446 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -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'); } }