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

fix capture groups for "each" statements #3274

Merged
merged 2 commits into from Feb 28, 2021

Conversation

error418
Copy link
Contributor

@error418 error418 commented Jul 3, 2020

Variables starting with of cause the regex to "drift" on capture groups

Example

each item of offers
  i= item

This causes

The value variable for each must either be a valid identifier (e.g. `item`) or a
pair of identifiers in square brackets (e.g. `[key, value]`).

Cause

The non-greedy (.*) matches the of of the variable for the of statement. This causes matching group misalignment, which leads to the displayed error.

Workaround

Rename your variable to something not starting with of 😊


fixes #3263
fixes #3275

improve capture group regex for `each` statements using a greedy match.

fixes pugjs#3263
@rollingversions
Copy link

rollingversions bot commented Jul 3, 2020

pug-lexer (5.0.0 → 5.0.1)

Bug Fixes

  • Variables starting with keywords cause the regex to "drift" on capture groups, causing errors

Packages With No Changes

The following packages have no user facing changes, so won't be released:

  • pug
  • pug-attrs
  • pug-code-gen
  • pug-error
  • pug-filters
  • pug-linker
  • pug-load
  • pug-parser
  • pug-runtime
  • pug-strip-comments
  • pug-walk

Edit changelogs

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

Successfully merging this pull request may close these issues.

Passing ["foo of bar"] to each causing a syntax error each fails with variable named "officers"
2 participants