-
Notifications
You must be signed in to change notification settings - Fork 264
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
Rspec tests fail on views with erb comments with single quotes #429
Comments
Might have time to look at it today. @glebm would it make sense to rescue in the parser and skip that node if it fails? E.g. if there is "wrong syntax" it will miss translations on that row as well? Should we print an error message? |
@davidwessman But why is it parsing a comment as code? |
Putting a space between a
Looks like a bug in the parser somewhere. Without a space we get this in handler missing for
With a space we get:
|
Ah, that seems to be a limit in better-html :/ I guess we could handle that AST-node for now |
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
@davidwessman I've given it a go at #430 |
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
Released v1.0.4 |
Thanks @davidwessman and @glebm for the super fast follow up 👍 |
I found that 1.0.x fails for me, and narrowed it down to erb comments that have single quotes in them, for example when used as a apostrophe in a sentence.
This is the simpelest test case I can make that reproduces the error:
<%# this will fail: ' %>
The rake tasks do work properly.
The text was updated successfully, but these errors were encountered: