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

regex for the cycle tag gives wrong results #179

Open
live627 opened this issue Feb 11, 2023 · 0 comments · May be fixed by #217
Open

regex for the cycle tag gives wrong results #179

live627 opened this issue Feb 11, 2023 · 0 comments · May be fixed by #217

Comments

@live627
Copy link

live627 commented Feb 11, 2023

Code to reproduce

{% cycle 44, "one", "three" %}
{% cycle "one", "two", "three" %}
{% cycle "one", "two ::,,ree" %}
{% cycle "one", "two ::,,ree" %}
{% cycle "namedd": "one", "two ::,,ree" %}

Expected output

44
one
one
two ::,,ree
one

Actual output

44
one
one

What happened?

$namedSyntax regex is too greedy, thinking that the strings before the colons are names.

/((?:(?:"[^"]*"|'[^']*')|(?:[^\s,\|'"]|(?:"[^"]*"|'[^']*'))+))\s*\:\s*(.*)/

Its output:

array (size=3)
  0 => string 'one", "two ::,,ree" ' (length=20)
  1 => string 'one", "two' (length=10)
  2 => string ':,,ree" ' (length=8)
array (size=3)
  0 => string 'one", "two ::,,ree" ' (length=20)
  1 => string 'one", "two' (length=10)
  2 => string ':,,ree" ' (length=8)

array (size=3)
  0 => string '"namedd": "one", "two ::,,ree" ' (length=31)
  1 => string '"namedd"' (length=8)
  2 => string '"one", "two ::,,ree" ' (length=21)

I'm crafting new ones to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant