From e285de60ce6a4fbb6077b9fb378f86fe486be80d Mon Sep 17 00:00:00 2001 From: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com> Date: Wed, 15 Apr 2026 15:48:43 +0300 Subject: [PATCH] Fix TEXT_REGEXP to use HTAB (\u0009) instead of VT (\u000b) Co-Authored-By: Claude Opus 4.6 Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com> Co-Authored-By: Nikita Skovoroda Signed-off-by: Nikita Skovoroda --- src/format.spec.ts | 13 +++++++++++++ src/index.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/format.spec.ts b/src/format.spec.ts index df54c58..f2db007 100644 --- a/src/format.spec.ts +++ b/src/format.spec.ts @@ -63,4 +63,17 @@ describe("format(obj)", function () { const obj = { type: "image/svg", parameters: { foo: "bar\u0000" } }; assert.throws(format.bind(null, obj), /Invalid parameter value: bar\u0000/); }); + + it("should quote parameter value containing HTAB", function () { + const str = format({ + type: "text/html", + parameters: { foo: "bar\tbaz" }, + }); + assert.strictEqual(str, 'text/html; foo="bar\tbaz"'); + }); + + it("should reject parameter value containing vertical tab", function () { + const obj = { type: "text/html", parameters: { foo: "bar\u000bbaz" } }; + assert.throws(format.bind(null, obj), /Invalid parameter value/); + }); }); diff --git a/src/index.ts b/src/index.ts index 945e7c8..be3490b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ * MIT Licensed */ -const TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]*$/; +const TEXT_REGEXP = /^[\u0009\u0020-\u007e\u0080-\u00ff]*$/; const TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; /**