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(core): avoid attribute names being scanned as symbols. Fixes #5673 #6624
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
No changes to documentation |
Component Testing Report Updated May 21, 2024 4:16 PM (UTC)
|
@@ -183,6 +183,10 @@ const cases = { | |||
}, | |||
], | |||
}, | |||
trueOrFalseField: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add a test that fails if this name is just true
or false
to make sure we didn't just break something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added explicit tests for parsing symbols versus attributes/identifiers
// need to make sure we don't inadvertently treat an attribute as a | ||
// symbol. For example, an attribute 'trueCustomerField' should not be | ||
// scanned as the boolean symbol "true". | ||
if (str[0].match(attributeCharMatcher)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we know what the perf hit is on looking ahead on each match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would only do this extra check when it encounters a symbol match which is all attribute-valid chars, meaning "true"
and "false"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks also for the added tests :)
merged in |
In the mutator package, we scan for certain symbols, among them "true" and "false". If an attribute name is prefixed with a symbol value, the string scanning will eagerly interpret it as a symbol instead of an attribute. This patch checks that there is no more valid attribute characters immediately after the potential symbol, so that the string "trueAttribute" will not be interpreted as the symbol "true".