mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
refactor: escaped characters within tag attributes
This commit is contained in:
parent
e862e242f7
commit
32800a14a8
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -7,17 +7,16 @@ showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text, opti
|
|||
text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.before', text, options, globals);
|
||||
|
||||
// Build a regex to find HTML tags.
|
||||
var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>)/gi,
|
||||
// due to catastrophic backtrace we split the old regex into two, one for tags and one for comments
|
||||
regexComments = /<!(--(?:|(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi;
|
||||
var tags = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,
|
||||
comments = /<!(--(?:(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi;
|
||||
|
||||
text = text.replace(regex, function (wholeMatch) {
|
||||
text = text.replace(tags, function (wholeMatch) {
|
||||
return wholeMatch
|
||||
.replace(/(.)<\/?code>(?=.)/g, '$1`')
|
||||
.replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
|
||||
});
|
||||
|
||||
text = text.replace(regexComments, function (wholeMatch) {
|
||||
text = text.replace(comments, function (wholeMatch) {
|
||||
return wholeMatch
|
||||
.replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user