fix: fix quadratic execution in em mask (#2818)

* fix: fix redos in em mask

* also remove (
pull/2821/head
Tony Brix 2023-05-26 11:50:39 -05:00 committed by GitHub
parent 46f4e5c2ff
commit a37fe8e82b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

View File

@ -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;

View File

@ -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] = {

View 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>`
}
];