fix: fix quadratic execution in em mask (#2818)
* fix: fix redos in em mask * also remove (
This commit is contained in:
parent
46f4e5c2ff
commit
a37fe8e82b
@ -187,7 +187,7 @@ inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
||||
inline.punctuation = edit(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex();
|
||||
|
||||
// sequences em should skip over [title](link), `code`, <html>
|
||||
inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
||||
inline.blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
|
||||
// lookbehind is not available on Safari as of version 16
|
||||
// inline.escapedEmSt = /(?<=(?:^|[^\\)(?:\\[^])*)\\[*_]/g;
|
||||
inline.escapedEmSt = /(?:^|[^\\])(?:\\\\)*\\[*_]/g;
|
||||
|
@ -111,9 +111,10 @@ export function loadFiles(dir) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
for (const spec of specs) {
|
||||
for (let i = 0; i < specs.length; i++) {
|
||||
const spec = specs[i];
|
||||
if (!spec.section) {
|
||||
spec.section = name;
|
||||
spec.section = `${name}[${i}]`;
|
||||
}
|
||||
if (!obj[spec.section]) {
|
||||
obj[spec.section] = {
|
||||
|
18
test/specs/redos/quadratic_em_mask.cjs
Normal file
18
test/specs/redos/quadratic_em_mask.cjs
Normal file
@ -0,0 +1,18 @@
|
||||
module.exports = [
|
||||
{
|
||||
markdown: '['.repeat(100000),
|
||||
html: `<p>${'['.repeat(100000)}</p>`
|
||||
},
|
||||
{
|
||||
markdown: '[.'.repeat(50000),
|
||||
html: `<p>${'[.'.repeat(50000)}</p>`
|
||||
},
|
||||
{
|
||||
markdown: '<'.repeat(100000),
|
||||
html: `<p>${'<'.repeat(100000)}</p>`
|
||||
},
|
||||
{
|
||||
markdown: '<.'.repeat(50000),
|
||||
html: `<p>${'<.'.repeat(50000)}</p>`
|
||||
}
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user