modxcms / revolution

MODX Revolution - Content Management Framework
https://modx.com/
GNU General Public License v2.0
1.36k stars 529 forks source link

Parser fails on nested output filters #14095

Closed goldsky closed 4 years ago

goldsky commented 6 years ago

Summary

Related issue: https://github.com/modxcms/revolution/issues/13250 . Parser fails to process nested output filters, and returns truncated tags.

Step to reproduce

Create a chunk called 'rowChunk' with this content:

[[+id:is=`1`:then=`[[+id]]`:else=`
    [[+id:is=`2`:then=`[[+id]]`:else=`
        [[+id:is=`3`:then=`[[+id]]`:else=`More`]]
    `]]
`]]

Then use the chunk as this:

[[!$rowChunk?
&id=`2`
]]

Try with &id=`3`

Observed behavior

It returns

More`]] `]] 

Expected behavior

It should return the defined value.

Environment

MODX 2.6.5-pl

Jako commented 5 years ago

@bezumkin Do you have an idea, what could happen here?

bezumkin commented 5 years ago

@Jako Problem is here

This expression couldn't handle nested conditions. Here what is happening: screenshot 2019-01-17 at 17 27 39

I can't fix it and, frankly, I don't use anything like this because of Fenom.

JoshuaLuckers commented 5 years ago

I will give it a try in the upcoming days 👍

goldsky commented 5 years ago

I am not sure if this is related, but how about changing the MODX's parsing order for nested tags, from inner outwards to outer inwards?

That means, the logic condition should start from the first tag and stop immediately once it meets the condition, without going further into the deeper nested tag(s).

bezumkin commented 5 years ago

@goldsky MODX parser always process tags inside out. Changing this will brake everything.

goldsky commented 5 years ago

Yeah, I know that irony. It shouldn't be at the first place.

JoshuaLuckers commented 5 years ago

I submitted a PR to fix this issue. Feel free to test the changes and provide feedback.

Ibochkarev commented 4 years ago

Fixed #14458 @goldsky Thanks @modxbot close