mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
perf: fix backtracking in padantic html (#4173)
This commit is contained in:
+3
-3
@@ -273,9 +273,9 @@ const blockGfm: Record<BlockKeys, RegExp> = {
|
||||
const blockPedantic: Record<BlockKeys, RegExp> = {
|
||||
...blockNormal,
|
||||
html: edit(
|
||||
'^ *(?:comment *(?:\\n|\\s*$)'
|
||||
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
||||
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
||||
'^ *(?:comment(?: *\\n|\\s*$)'
|
||||
+ '|<(tag)[\\s\\S]+?</\\1>(?: *\\n{2,}|\\s*$)' // closed tag
|
||||
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?>(?: *\\n{2,}|\\s*$))')
|
||||
.replace('comment', _comment)
|
||||
.replace(/tag/g, '(?!(?:'
|
||||
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
options: { pedantic: true, gfm: false },
|
||||
markdown: '<test>a</test>' + ' '.repeat(50000) + 'b',
|
||||
html: '<p><test>a</test> b</p>\n',
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
options: { pedantic: true, gfm: false },
|
||||
markdown: '<!-->' + ' '.repeat(50000) + 'b',
|
||||
html: '<!--> b\n',
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
options: { pedantic: true, gfm: false },
|
||||
markdown: '<test/>' + ' '.repeat(50000) + 'b',
|
||||
html: '<p><test/> b</p>\n',
|
||||
};
|
||||
Reference in New Issue
Block a user