From 512b1e7296b8f80853eb4c0a2feeceb2b1f8021e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 20 Jan 2026 11:17:30 -0500 Subject: [PATCH] fix: remove lowercase bidi controls as well --- public/src/utils.common.js | 2 +- test/utils.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/public/src/utils.common.js b/public/src/utils.common.js index 873292d22e..a35c6a2ea0 100644 --- a/public/src/utils.common.js +++ b/public/src/utils.common.js @@ -301,7 +301,7 @@ const utils = { return String(str).replace(new RegExp('<(\\/)?(' + (pattern || '[^\\s>]+') + ')(\\s+[^<>]*?)?\\s*(\\/)?>', 'gi'), ''); }, stripBidiControls: function (input) { - return input.replace(/[\u202A-\u202E\u2066-\u2069]/g, ''); + return input.replace(/[\u202A-\u202E\u2066-\u2069]/gi, ''); }, cleanUpTag: function (tag, maxLength) { if (typeof tag !== 'string' || !tag.length) { diff --git a/test/utils.js b/test/utils.js index 2e0ce72e8a..cd5ec12a4b 100644 --- a/test/utils.js +++ b/test/utils.js @@ -51,6 +51,12 @@ describe('Utility Methods', () => { assert.strictEqual(out, 'Hello World Dwellers'); }); + it('should remove common bidi embedding and override controls if they are lowercase', () => { + const input = '\u202aHello\u202c \u202bWorld\u202c \u202dDwellers\u202e'; + const out = utils.stripBidiControls(input); + assert.strictEqual(out, 'Hello World Dwellers'); + }); + it('should remove bidirectional isolate formatting characters', () => { const input = '\u2066abc\u2067def\u2068ghi\u2069'; const out = utils.stripBidiControls(input);