Fix decimal alias negative values with prefix/groupSeparator collision (#2262)#2882
Open
thorn0 wants to merge 1 commit into
Open
Fix decimal alias negative values with prefix/groupSeparator collision (#2262)#2882thorn0 wants to merge 1 commit into
thorn0 wants to merge 1 commit into
Conversation
…RobinHerbots#2262 Three root causes fixed in the numeric extensions: 1. Register the groupSeparator definition before autoEscape(prefix) so that a shared character (e.g. space in prefix "€ " with groupSeparator " ") is escaped as a literal in the mask instead of being treated as a dynamic placeholder by the lexer. 2. In onBeforeWrite's strip-negation-on-zero path, match against the raw buffer instead of the stripped buffer so that prefix/suffix characters coinciding with the groupSeparator are not accidentally removed. Extract the shared regex into a reusable matchNumberInWrapper() helper. 3. Guard the radixPoint replacement with a truthiness check to prevent "".replace("", ".") from injecting a stray "." when radixPoint is empty (radix-less masks with empty placeholder). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c472d47 to
a0df91f
Compare
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.
Closes #2262, closes #2678, closes #2771
Summary
Three root causes fixed in the numeric extensions:
groupSeparator definition ordering — Register the
groupSeparatordefinition beforeautoEscape(prefix)so that a shared character (e.g. space in prefix"€ "withgroupSeparator: " ") is escaped as a literal in the mask instead of being treated as a dynamic placeholder by the lexer.strip-negation-on-zero matching — In
onBeforeWrite's strip-negation-on-zero path, match against the raw buffer instead of the stripped buffer so that prefix/suffix characters coinciding with thegroupSeparatorare not accidentally removed. Extracted the shared regex into a reusablematchNumberInWrapper()helper.empty radixPoint guard — Guard the
radixPointreplacement with a truthiness check to prevent"".replace("", ".")from injecting a stray"."whenradixPointis empty (radix-less masks with empty placeholder).Test plan
tests_formatvalidate.jscovering:isValid/formatwith negative values + prefix + groupSeparator"€ ")" €")-1 234 567.89)radixPoint: "") with integer/decimal/numeric aliasesnegationSymbol: { front: "(", back: ")" })AI disclosure
This PR was written primarily by Claude Code. Follow-up fixes were reviewed and amended by Codex.