mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
closes #6023
This commit is contained in:
@@ -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'),
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user