Linter: Fix html-no-unescaped-entities false positive on ActionView tag helpers#1672
Conversation
89101c5 to
d33a4d6
Compare
html-no-unescaped-entities false positive on ActionView tag helpers
d33a4d6 to
83fd89c
Compare
Add an escape_content flag to HTMLElementNode so virtual elements created from ActionView helpers can track whether generated content is escaped. Use that flag in html-no-unescaped-entities to avoid false positives for escaped helper content while still linting raw-safe helper output. Update generated bindings and snapshots for the new AST shape.
83fd89c to
2238fc5
Compare
|
@marcoroth rebased and tests should be fixed now, could you kick off another CI run please? |
|
|
||
| get parserOptions(): Partial<ParserOptions> { | ||
| return { | ||
| action_view_helpers: true, |
There was a problem hiding this comment.
Hey @bdewater-thatch, thanks for taking a stab at fixing this!
I'd need to check, but couldn't we just disable the action_view_tag_helpers option on this linter rule, so that the linter doesn't even see the converted ActionView helpers as HTML nodes?
Or is the automatic escaping only happening on some of the Action View helpers?
There was a problem hiding this comment.
Actually, I wonder if we should handle this in the transformation logic in the parser itself where we translate the Action View Helpers to the raw HTML nodes to directly escape what needs to be escaped.
There was a problem hiding this comment.
Thanks for the comments @marcoroth - let me explore that direction. Automatic escaping is conditional on arguments passed in or whether the block form is used.
#1670 was actually correct, the agent hallucinated the rule being enabled or not 😂
The html-no-unescaped-entities rule flags
&characters inside string arguments to ActionView tag helpers that auto-escape their content by default. Following the suggested fix (&) causes double-escaping and the user sees literal&instead of&.Decided to let it take a stab at fixing it because I don't want people to get too comfortable with disabling this rule.