Repository navigation
fix: validate client state JavaScript identifiers - #7595
harsh21234i wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
[Medium impact] The PR appears safe to merge, with a remaining non-blocking limit on accepted Unicode names. Findings
SummaryAdds checks for
Reviews (2) · Last reviewed commit: "fix: cover client state identifier edge ..." · Reviewed by Greptile |
| Whether the name is a valid binding that does not conflict with generated code. | ||
| """ | ||
| return ( | ||
| var_name.replace("$", "_").isidentifier() |
There was a problem hiding this comment.
Valid Unicode names are rejected
Python's isidentifier() rejects some valid JavaScript names. For example, "value\u200cname" contains a zero-width non-joiner, which JavaScript permits after the first character but Python rejects. This now raises ValueError for a name that previously produced valid JavaScript. Use JavaScript's identifier rules and cover these Unicode differences in the tests.
Merging this PR will not alter performance
|
ClientStateVar names are used as JavaScript bindings, so invalid identifiers or names that conflict with reserved words and generated Reflex bindings can produce broken frontend code.
Validate names when creating a ClientStateVar, and add tests covering rejected names and valid identifiers.
Fixes #6828.
Tests: 27 targeted tests passed; isolated Ruff check passed.