fix: remove lowercase bidi controls as well

This commit is contained in:
Barış Soner Uşaklı
2026-01-20 11:17:30 -05:00
parent 635715ef51
commit 512b1e7296
2 changed files with 7 additions and 1 deletions

View File

@@ -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) {

View File

@@ -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);