TYPO3 / Fluid

Fluid template rendering engine - Standalone version
GNU Lesser General Public License v3.0
151 stars 93 forks source link

Fluid Template Variable Parsing Error with Spaces around Operators #895

Closed garvinhicking closed 2 weeks ago

garvinhicking commented 1 month ago

From: https://forge.typo3.org/issues/104363

h2. Steps to Reproduce:

Use the following Fluid template code:


testVar: {testVar} 
A: {testVar - 1}
B: {testVar - 1 }
C: {testVar-1}
D: {testVar + 1}
E: {testVar + 1 }
F: {testVar+1}

Set testVar to any integer, e.g., 2.

h3. Expected Output:

testVar: 2
A: 1
B: 1
C: 1
D: 3
E: 3
F: 3

h3. Actual Output:

testVar: 2
A: 1
B: {testVar - 1 }
C:
D: 3
E: {testVar + 1 }
F: 3

h2. Analysis:

s2b commented 2 weeks ago

Case C isn't and won't be supported because testVar-1 is treated as a variable identifier. This is especially useful for array keys properties:

{myVar.my-array-key.test}

The leading/trailing whitespace are addressed with the attached PR.