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

Curly braces in a conditional with a regex throws parsing error #29

Closed
litzinger opened this issue Nov 29, 2018 · 2 comments
Closed

Curly braces in a conditional with a regex throws parsing error #29

litzinger opened this issue Nov 29, 2018 · 2 comments
Labels
Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on.

Comments

@litzinger
Copy link
Contributor

Description of the problem
Using curly braces in a regex comparison in a conditional causes a parsing error. I have a situation where I need to detect if a segment is a valid ISO code, e.g. en-us, or ca-fr. It appears as if the conditional parser is choking on the curly braces in the regex, b/c as soon as they are removed the error message goes away, but of course the regex isn't matching what I need it to match.

How To Reproduce
Steps to reproduce the behavior:
Add the following to a template file, and it'll yield the error message below.
{if segment_2 ~ "/\S{2}-\S{2}/"}{/if}

Error Messages


You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}.

Environment Details:

  • Version: 4.3.6
  • PHP Version: 7.1
  • MySQL Version: 5.7
  • OS: Linux (via Vagrant)
  • Web Server: Apache
@derekjones
Copy link

I haven't confirmed this report yet, but as a workaround you should be able to use '/\S\S-\S\S/'.

@kevincupp kevincupp added the Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on. label Nov 30, 2018
@litzinger
Copy link
Contributor Author

I actually converted to using Resource Router as it was easier to handle 4 url variations the same template, and keep this sort of logic out of the template file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on.
Projects
None yet
Development

No branches or pull requests

3 participants