01579: when pcre.backtrack_limit is exceeded in MarkupToHTML display user message

Summary: when pcre.backtrack_limit is exceeded in MarkupToHTML display user message
Created: 2026-11-24 18:53
Status: Open
Category: Feature
From: simon
Assigned:
Priority:
Version: latest
OS:

Description: When the pcre.backtrack_limit is exceeded in MarkupToHTML() PmWiki silently fails by showing blank output. This can be extremely difficult to diagnose.

Instead of MarkupToHTML() returning null the suggestion is to return a message.
For example here is a tested example from pmwiki.php fron line ~3160; see the lines marked
## user message

    foreach($markrules as $p=>$r) {
      list($r, $id) = (array)$r;
      $GLOBALS['MarkupToHTML']['markupid'] = $id;
      if ($p[0] == '/') {
        if (is_callable($r)) {
            $x = preg_replace_callback($p,$r,$x);
            if (\is_null ($x)) {
                $x = 'MarkupToHTML: preg_replace_callback pcre.backtrack_limit error'; ## user message
            }
        } else {
            $x=preg_replace($p,$r,$x); # simple text OR called by old addon|skin|recipe needing update, see pmwiki.org/Troubleshooting
            if (\is_null ($x)) {
                $x = 'MarkupToHTML: preg_replace pcre.backtrack_limit error'; ## user message
            }
        }
      }
      elseif (strstr($x,$p)!==false) {
        $vars = [
          'pagename' => &$pagename,
          'out' => &$out,
          'x' => &$x,
          'p' => &$p,
          'r' => &$r,
          'id' => &$id,
          'text' => &$text,
          'opt' => &$opt,
          'lines' => &$lines,
          'markrules' => &$markrules,
        ];

        if (is_callable($r)) {
            $x = CallbackWithArgs($r, $vars);
            if (\is_null ($x)) {
                $x = 'MarkupToHTML: CallbackWithArgs failed'; ## user message
            }
        } else {
            $x=PEVAL($r, $vars);
            if (\is_null ($x)) {
                $x = 'MarkupToHTML: PEVAL failed'; ## user message
            }
        }
      } 
simon

ChangeLog?action=diff#diff1795524697 Will this from 7 hours ago work? It can be one of several PCRE errors, all should display a message. --Petko