Skip to content

Node.js based forum software built for the modern web

closes #6023

Baris Usaklic9465403f5b2
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('</?(?:' + pattern + ')[^<>]*>', '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('<p>just <b>some</b> text</p>'), 'just some text');
assert.strictEqual(utils.stripHTMLTags('<p>just <b>some</b> text</p>', ['p']), 'just <b>some</b> text');
+ assert.strictEqual(utils.stripHTMLTags('<i>just</i> some <image/> text', ['i']), 'just some <image/> text');
+ assert.strictEqual(utils.stripHTMLTags('<i>just</i> some <image/> <div>text</div>', ['i', 'div']), 'just some <image/> text');
done();
});