| #
b22130d2
|
| 08-Jul-2026 |
Andreas Gohr <gohr@cosmocode.de> |
fix(parser): stop group-quantifier body patterns from exhausting memory
Several patterns repeat a group — (?:…)* / (?:…)+ — over a body that can span a large region. On the non-JIT PCRE engine each
fix(parser): stop group-quantifier body patterns from exhausting memory
Several patterns repeat a group — (?:…)* / (?:…)+ — over a body that can span a large region. On the non-JIT PCRE engine each iteration of a group repetition keeps its own backtracking frame, so a big body retains one frame per byte: a linear, unbounded memory spike that can fatal a request (and, with JIT on, trips pcre.jit_stacklimit so the lexer dumps the rest of the document as literal text). A repetition over a single item (.* , [^x]+) is optimized by PCRE and unaffected.
Make each body possessive: the repeated group cannot match the delimiter that follows it, so it always stops at the first closer and never needs to backtrack.
- media {{…}}, windowssharelink, gfm_quote, gfm_link: possessive body. - email validation (used by emaillink and mail_isvalid): possessive local-part and domain groups; a long dotted `a.a.a…` local part or domain was a ReDoS vector. Match results are unchanged.
show more ...
|
| #
73dc0a89
|
| 06-May-2026 |
Andreas Gohr <andi@splitbrain.org> |
fix(mail): keep '&' intact in mailto links with multiple query params
Move the email-handling helpers (obfuscate, mail_isvalid, mail_quotedprintable_encode, mail_setup) out of the procedural inc/mai
fix(mail): keep '&' intact in mailto links with multiple query params
Move the email-handling helpers (obfuscate, mail_isvalid, mail_quotedprintable_encode, mail_setup) out of the procedural inc/mail.php into a namespaced dokuwiki\MailUtils class plus a new Mailer::configInit(), and add a separate MailUtils::obfuscateUrl() for the mailto-href context.
The xhtml renderer and PluginTrait now build the link label and the href separately: the address half is run through the mailguard obfuscation, the query string is preserved verbatim with only HTML escaping applied. This fixes #1690 — in 'visible' mode the previous code rawurlencoded the entire address+query, turning '?' into '%3F' and breaking multi-parameter mailto links; in all modes the query string is no longer mangled by the [at]/[dot] substitution.
Core call sites (Mailer, auth, LegacyApiCore, common, the xhtml renderer, the parser, the bundled config/styling/usermanager plugins) are migrated to MailUtils directly. The old top-level functions and PREG_PATTERN_VALID_EMAIL constant remain as deprecated shims with rector mappings.
Tests for obfuscate / mail_isvalid / mail_quotedprintable_encode are consolidated into a single _test/tests/MailUtilsTest.php and extended with regression coverage for the multi-parameter, double-escape and URL-shape cases.
Closes #1690 Replaces #1964
show more ...
|