Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FeatureInfo: conditional rendering fails if string to be checked contains an equal sign ("=") #1277

Closed
jacobwod opened this issue Feb 1, 2023 · 0 comments
Assignees
Labels
bug module:client/core Core functionality (not a plugin)
Milestone

Comments

@jacobwod
Copy link
Member

jacobwod commented Feb 1, 2023

Describe the bug
As of #669 we have a conditional check ({{if foo="bar}}). #1128 introduced a != notation too.

The portion of code that does the actual parsing looks like this:

if (matched.attributes?.includes("=")) {

The problem with this is that if the matched attribute value contains a "=" (which can happen if it's e.g. a URL with query params) the code above will evaluate to true, we will split the string (URL in our example) in half and try to do an equality check which, naturally, will fail.

Short-term solution

Try to determine if a attribute is an URL. If so, don't do the conditional check, use only length check. **In practical terms, this would mean that if a string looks like an URL, it will be impossible to compare its value, e.g. no {{if {url}=https://www.example.com}}}. If url has a value, the check will evaluate to true, always.

Proposed long-term solution

We should probably give up our custom markup and move to some well-used template engine, e.g. https://github.com/sstur/jinja-js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug module:client/core Core functionality (not a plugin)
Projects
None yet
Development

No branches or pull requests

1 participant