Node.js based forum software built for the modern web
fix: remove lowercase bidi controls as well
Barış Soner Uşaklı512b1e7296b8
diff --git a/public/src/utils.common.js b/public/src/utils.common.jsindex 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.jsindex 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);