fix(acceptance): match field names by \p{ID_Continue} boundary, not raw substring#201
Open
agjs wants to merge 1 commit into
Open
fix(acceptance): match field names by \p{ID_Continue} boundary, not raw substring#201agjs wants to merge 1 commit into
agjs wants to merge 1 commit into
Conversation
`fieldIsMentioned` (acceptance-spec.ts) associated a field with a plan constraint via `constraintLower.includes(field.name.toLowerCase())` — a raw SUBSTRING match. A short field name is then matched by any longer word that merely contains it: `id` inside `valid`, `age` inside `manage`, so a constraint like "must be a valid email" wrongly reports field `id` as mentioned and fabricates a spurious negative acceptance case for it. Match on WORD BOUNDARIES instead (`\b<name>\b`, escaped), for both the raw and humanized forms. Genuine whole-word mentions (`email` in "a valid email", the humanized "first name" of `firstName`) still match; substring false positives no longer do. `fieldIsMentioned` is now exported and unit-tested (positive: email / name / humanized firstName; negative: id-in-valid, age-in-manage, and an unrelated word). Existing acceptance-spec suite unaffected (12 pass); typecheck + lint clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by a proactive bug-hunt.
fieldIsMentioned(acceptance-spec.ts) associated a field with a plan constraint viaconstraintLower.includes(field.name.toLowerCase())— a raw substring match. A short field name is then matched by any longer word that merely contains it (idinsidevalid,ageinsidemanage), fabricating a spurious negative acceptance test case for a field the constraint never mentions.Fix: guard the match with lookarounds over
\p{ID_Continue}— the exact Unicode identifier-continue property — for both the raw and humanized forms. A match is rejected only when glued to an adjacent identifier char, killing the substring case across ASCII, non-ASCII (âgeinpréâge), combining marks (age+U+0301), and Other_ID_Continue glue (_, digits, ZWJ), while still matching names that begin/end with a non-identifier char (price$,$ref) or are non-ASCII whole words (âge).\b/\wstay ASCII-only under/u.fieldIsMentionedis now exported and unit-tested — positive, negative (id-in-valid,age-in-manage), and full boundary coverage (empirically verified\p{ID_Continue}membership incl. ZWJ/ZWNJ/middle-dot in Bun).Panel: PASS (4/4). Existing acceptance-spec suite unaffected; full suite green; typecheck + lint clean.