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

Fixes parsing of ERB comments without a space #430

Merged
merged 1 commit into from
Mar 25, 2022
Merged

Conversation

glebm
Copy link
Owner

@glebm glebm commented Mar 25, 2022

The ERB parser we're using misparses comments of the form:

<%# ... #>

(no space between % and #)

With a space the AST is:

s(:erb, nil, nil,
  s(:code, " # this should not fail: ' "), nil)

Without a space the AST is:

s(:erb,
  s(:indicator, "#"), nil,
  s(:code, " this should not fail: ' "), nil)

The latter AST causes a crash when parsing the :code node as Ruby.

Works around the issue by transforming the latter AST to the former.

Fixes #429

The ERB parser we're using misparses comments of the form:

    <%# ... #>

(no space between % and #)

With a space the AST is:

    s(:erb, nil, nil,
      s(:code, " # this should not fail: ' "), nil)

Without a space the AST is:

    s(:erb,
      s(:indicator, "#"), nil,
      s(:code, " this should not fail: ' "), nil)

The latter AST causes a crash when parsing the `:code` node as Ruby.

Works around the issue by transforming the latter AST to the former.

Fixes #429
@glebm glebm merged commit ef007fb into main Mar 25, 2022
@glebm glebm deleted the fix-erb-misparse branch March 25, 2022 09:38
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.

Rspec tests fail on views with erb comments with single quotes
2 participants