diff --git a/src/rules.js b/src/rules.js index 322825bbcb..02610c7d26 100644 --- a/src/rules.js +++ b/src/rules.js @@ -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`, -inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g; +inline.blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g; // lookbehind is not available on Safari as of version 16 // inline.escapedEmSt = /(?<=(?:^|[^\\)(?:\\[^])*)\\[*_]/g; inline.escapedEmSt = /(?:^|[^\\])(?:\\\\)*\\[*_]/g; diff --git a/test/helpers/load.js b/test/helpers/load.js index 77cd6a8f1f..4aa650944b 100644 --- a/test/helpers/load.js +++ b/test/helpers/load.js @@ -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] = { diff --git a/test/specs/redos/quadratic_em_mask.cjs b/test/specs/redos/quadratic_em_mask.cjs new file mode 100644 index 0000000000..e71155e1a4 --- /dev/null +++ b/test/specs/redos/quadratic_em_mask.cjs @@ -0,0 +1,18 @@ +module.exports = [ + { + markdown: '['.repeat(100000), + html: `
${'['.repeat(100000)}
` + }, + { + markdown: '[.'.repeat(50000), + html: `${'[.'.repeat(50000)}
` + }, + { + markdown: '<'.repeat(100000), + html: `${'<'.repeat(100000)}
` + }, + { + markdown: '<.'.repeat(50000), + html: `${'<.'.repeat(50000)}
` + } +];