diff --git a/public/src/utils.js b/public/src/utils.js index 328c73ebe0..0e300d2772 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -333,7 +333,7 @@ var pattern = (tags || ['']).map(function (tag) { return utils.escapeRegexChars(tag); }).join('|'); - return String(str).replace(new RegExp(']*>', 'gi'), ''); + return String(str).replace(new RegExp('<(\\/)?(' + (pattern || '[^\\s>]+') + ')(\\s+[^<>]*?)?\\s*(\\/)?>', 'gi'), ''); }, invalidUnicodeChars: XRegExp('[^\\p{L}\\s\\d\\-_]', 'g'), diff --git a/test/utils.js b/test/utils.js index e76c1b9bff..4c69b235e0 100644 --- a/test/utils.js +++ b/test/utils.js @@ -35,6 +35,8 @@ describe('Utility Methods', function () { it('should strip HTML tags', function (done) { assert.strictEqual(utils.stripHTMLTags('

just some text

'), 'just some text'); assert.strictEqual(utils.stripHTMLTags('

just some text

', ['p']), 'just some text'); + assert.strictEqual(utils.stripHTMLTags('just some text', ['i']), 'just some text'); + assert.strictEqual(utils.stripHTMLTags('just some
text
', ['i', 'div']), 'just some text'); done(); });