MODX 3.02, input output filters

Output modifiers in modx 3 does not work like expected if (single) square brackets used in modifier strings.

Step to reproduce

Create a ressource named “strange” with following content:

<pre>
[[*pagetitle:is=`foo`:then=`bar[not baz]`:else=`baz[not bar]`]]
[[*pagetitle:is=`foo`:then=`baz`:else=`bar`]]
</pre>

Observed behavior (output)

strange
baz

Expected behavior (output)

baz[not bar]
bar

Environment

Apache/2.4.51 (Linux/SUSE)
PHP Version 7.4.33
mysql Ver 15.1 Distrib 10.6.10-MariaDB, for Linux (x86_64)

Issue is caused by core/src/Revolution/src/modInputFilter.php line 52 - 142. Without going deeper in code, i suspect, the new implemented charbased handling on filtered elements breaks something…
As a first workaround i changed (revert) lines to (from working modx 2.x):

        if ($splitPos !== false && $splitPos > 0) {
            $matches= array ();
            $name= trim(substr($output, 0, $splitPos));
            $modifiers= substr($output, $splitPos);
            if (preg_match_all('~:([^:=]+)(?:=`(.*?)`[\r\n\s]*(?=:[^:=]+|$))?~s', $modifiers, $matches)) {
                $command = $matches[1];
                $commandModifiers = $matches[2];
            }
        }

        if (!empty($command)) {
            $this->_commands = $command;
            $this->_modifiers = $commandModifiers;
        }

Did anyone else experience this issue?

Regards, Stephan

There is an error in MODX 3.0.2 that affects single square brackets.

Apply this pull request (the file core/src/Revolution/Filters/modInputFilter.php). It should fix the issue:

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.