Skip to content

Ensure filters/attributes aren't mistaken for operators#4774

Merged
fabpot merged 1 commit intotwigphp:3.xfrom
brandonkelly:bugfix/4767-filter-attribute-operator-conflict
Feb 24, 2026
Merged

Ensure filters/attributes aren't mistaken for operators#4774
fabpot merged 1 commit intotwigphp:3.xfrom
brandonkelly:bugfix/4767-filter-attribute-operator-conflict

Conversation

@brandonkelly
Copy link
Copy Markdown
Contributor

Updates the regex in Lexer::getOperatorRegex() to account for filters/attributes that have a space between their |/. operator and the filter/attribute name, to ensure they aren’t mistaken for operators.

A test is included that checks the following template.

{{ 'foo'|and }}
{{ 'bar' | and }}
{{ foo.and }}
{{ bar . and }}
{{ foo and bar }}

(Only the and in the last tag should be considered an operator.)

Fixes #4767

@fabpot fabpot force-pushed the bugfix/4767-filter-attribute-operator-conflict branch from 60437a3 to a9ac993 Compare February 24, 2026 20:10
@fabpot
Copy link
Copy Markdown
Contributor

fabpot commented Feb 24, 2026

Thank you @brandonkelly.

@fabpot fabpot merged commit 2ec5479 into twigphp:3.x Feb 24, 2026
@brandonkelly brandonkelly deleted the bugfix/4767-filter-attribute-operator-conflict branch February 24, 2026 21:59
fabpot added a commit that referenced this pull request Feb 25, 2026
… separate operator token registration from parser identity (fabpot)

This PR was merged into the 3.x branch.

Discussion
----------

Add getOperatorTokens() to ExpressionParserInterface to separate operator token registration from parser identity

Closes #4767
Closes #4774

Commits
-------

e5eb95d Add getOperatorTokens() to ExpressionParserInterface to separate operator token registration from parser identity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

literal filter/operator conflict

2 participants