mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-14 02:27:49 +01:00
fix: remove lowercase bidi controls as well
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user