Skip to content

Commit

Permalink
fix(core): avoid attribute names being scanned as symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
runeb committed May 10, 2024
1 parent 680d428 commit 9077fa6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/@sanity/mutator/src/jsonpath/tokenize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ class Tokenizer {
return null
}
if (str === this.source.slice(this.i, this.i + str.length)) {
// When checking symbols that consist of valid attribute characters, we
// 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)) {
// check that char following the symbol match is not also an attribute char
if (this.length > this.i + str.length) {
const nextChar = this.source[this.i + str.length]
if (nextChar && nextChar.match(attributeCharMatcher)) {
return null
}
}
}
this.i += str.length
return str
}
Expand Down

0 comments on commit 9077fa6

Please sign in to comment.