Skip to content

Commit 6054770

Browse files
author
Jiang Shang
committed
bugfix
1 parent 95119d3 commit 6054770

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

dist/Parser.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,15 @@ var Parser = (function () {
244244
return '<a href="' + p1 + '">' + p1 + '</a>';
245245
});
246246

247-
// encode unsafe tags
248-
var unsafeTagMatches = /<(\/?)([a-z0-9-]+)(\s+[^>]*)?>/i.exec(text);
249-
if (unsafeTagMatches) {
250-
var whiteLists = this.commonWhiteList + '|' + whiteList;
251-
if (whiteLists.toLowerCase().indexOf(unsafeTagMatches[2].toLowerCase()) !== -1) {
252-
return this.makeHolder(unsafeTagMatches[0]);
247+
text = text.replace(/<(\/?)([a-z0-9-]+)(\s+[^>]*)?>/ig, function (match, p1, p2, p3) {
248+
var whiteLists = _this3.commonWhiteList + '|' + whiteList;
249+
if (whiteLists.toLowerCase().indexOf(p2.toLowerCase()) !== -1) {
250+
return _this3.makeHolder(match);
253251
} else {
254-
return this.htmlspecialchars(unsafeTagMatches[0]);
252+
return _this3.htmlspecialchars(match);
255253
}
256-
}
257-
console.log(text);
254+
});
255+
258256
text = text.replace(/</g, '&lt;');
259257
text = text.replace(/>/g, '&gt;');
260258

0 commit comments

Comments
 (0)