| #
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 ...
|
| #
71096e46
|
| 18-Apr-2026 |
Andreas Gohr <andi@splitbrain.org> |
move handler methods into ParserMode classes and rename Handler
Each ParserMode class now implements handle() from ModeInterface, containing the token handling logic that previously lived as individ
move handler methods into ParserMode classes and rename Handler
Each ParserMode class now implements handle() from ModeInterface, containing the token handling logic that previously lived as individual methods on Doku_Handler.
The Handler class (formerly Doku_Handler) is the single dispatch point: Lexer passes tokens to Handler::handleToken() which routes to mode objects, plugins, or returns false. The Lexer only tokenizes and resolves mapHandler aliases.
Key changes: - Add handle() to ModeInterface, implemented by all mode classes - Move Doku_Handler to dokuwiki\Parsing\Handler namespace - File extends Code (shared parsing via $type property) - Quotes uses mapHandler() + Handler::getModeName() for sub-modes - Media::parseMedia() replaces Doku_Handler_Parse_Media() - Code::parseHighlightOptions() replaces parse_highlight_options() - Per-parse state (footnote, doublequote) stays on Handler - Deprecated wrappers kept for base/header/internallink/media - Class alias and rector rules added for backward compatibility
show more ...
|