fix(isa-utils): function replacer in appendDecisionRow so ISA dollar amounts don't backref-expand - #2045
Closed
alexfry-axeai wants to merge 1 commit into
Closed
Conversation
…amounts don't backref-expand appendDecisionRow appended its auto-rewind row with a STRING replacement built from the existing Decisions body. That body carries literal dollar amounts, and String.prototype.replace interprets $1/$2/$& in a replacement string as regex backreferences, so an amount like $14,000 expanded to <capture-group-1>4,000 — duplicating the ## Decisions header and shredding the section on any resume of a completed ISA. Switch to a function replacer, whose return value is inserted verbatim. Adds a regression test (synthetic amounts).
Owner
|
Ported with credit, test included. Closing, next release. Thanks. |
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.
What
appendDecisionRow(inLifeOS/install/hooks/lib/isa-utils.ts) appends the auto-rewind Decisions row using a string replacement built from the existing Decisions body:The bug
That Decisions body routinely contains literal dollar amounts.
String.prototype.replaceinterprets$1,$2,$&, etc. in a replacement string as regex backreferences — so an amount like$14,000is read as capture group 1 followed by4,000. On any resume of a completed ISA, the rewrite expands those into the captured section text, duplicating the## Decisionsheading and shredding the section (a$14,000becomes<group-1>4,000, with fragment lines and repeated headers).The fix
Use a function replacer, whose return value is inserted verbatim with no
$interpretation:One line of behavior change, plus a short explanatory comment.
appendDecisionRowis exported so it can be unit-tested.Test
Adds
isa-utils.test.ts, a regression test using synthetic$1/$2/$3/$4-prefixed amounts. It asserts every amount survives intact, exactly one## Decisionsheading remains, and the rewind row lands under Decisions. Fails on the old string replacement, passes on the fix.