Repository navigation
fix(core): insert template values verbatim to prevent $-sequence corr… - #55320
gorredinesh21 wants to merge 1 commit into
Conversation
…uption String.prototype.replace interprets $-sequences ($&, $', $`, $$) in string replacements. Filling templates with user-controlled values (file paths, project directories) via a string replacer silently corrupts the result: - formatter argv: a path like /tmp/a$&b.ts becomes /tmp/a$FILEb.ts, so the formatter is invoked on a nonexistent file - /init and /review command templates: a project path containing $' mangles the assembled prompt Add literalReplace() (function-replacer form, matching the existing $ARGUMENTS fill in plugin/command.ts) and migrate the affected call sites. First-match semantics are preserved.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 72 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
Thanks for following up on this fix! This still looks like a duplicate of #54918, which is open and fixes #52314 at the same three places: If you think #54918 should use a shared helper or test more cases ( |
…uption
String.prototype.replace interprets$-sequences ($ &, $', $ `, $$) in string replacements. Filling templates with user-controlled values (file paths, project directories) via a string replacer silently corrupts the result:
Add literalReplace() (function-replacer form, matching the existing $ARGUMENTS fill in plugin/command.ts) and migrate the affected call sites. First-match semantics are preserved.
Issue for this PR
Closes #
Type of change
What does this PR do?
Please provide a description of the issue, the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the PR.
If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!
How did you verify your code works?
Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist
If you do not follow this template your PR will be automatically rejected.