From c6b22e89baca9dfa4ed074380a511781e1c35e4a Mon Sep 17 00:00:00 2001 From: Gss <28855686+shuishui313@users.noreply.github.com> Date: Tue, 17 Nov 2026 02:20:08 +0800 Subject: [PATCH] fix: avoid quadratic time on long local part before @ in GFM text (#4225) --- src/rules.ts | 2 +- test/specs/redos/quadratic_email_at.cjs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test/specs/redos/quadratic_email_at.cjs diff --git a/src/rules.ts b/src/rules.ts index 1e41f1a0..601c598a 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -604,7 +604,7 @@ const inlineGfm: Record = { .getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, - text: edit(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\${'a'.repeat(50000)}@

`, +};