fix(format): preserve literal replacement characters in values - #21751
Conversation
|
Thanks for your contribution! Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only. |
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation correctly resolves the replacement-string issue with adequate regression coverage.
Pull request overview
Fixes formatter substitutions so dollar sequences in values remain literal.
Changes:
- Uses callback replacements in both template formatters.
- Adds coverage for HTML encoding, indexed series, and numeric values.
File summaries
| File | Description |
|---|---|
src/util/format.ts |
Preserves literal replacement characters. |
test/ut/spec/util/format.test.ts |
Adds formatter regression tests. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
plainheart
left a comment
There was a problem hiding this comment.
Hi, thanks for your contribution! I plan to include it in v6.1.1. Can you change the target branch to the release branch?
Signed-off-by: Hanabi <317387557+Hanabi9248@users.noreply.github.com>
Signed-off-by: Hanabi <317387557+Hanabi9248@users.noreply.github.com>
a36061b to
5e78e20
Compare
|
Retargeted to |
|
Congratulations! Your PR has been merged. Thanks for your contribution! 👍 |
Brief Information
What does this PR do?
Preserves literal dollar sequences in values inserted into formatter templates.
Details
Before: What was the problem?
Formatting
{a}with a series name ofPrice $$returnsPrice $. A name containing$&can reinsert the placeholder instead of displaying the name, including when HTML encoding is enabled.Both
formatTplandformatTplSimplepass values directly as replacement strings, soString.replaceinterprets these sequences.After: How does it behave after the fixing?
Callback replacements insert the values literally. HTML encoding and indexed series formatting stay unchanged.
Document Info
Misc
Related test cases or examples to use the new APIs
Three tests cover literal replacement sequences with and without HTML encoding, simple templates, indexed series, and numeric values. All three fail before the fix.
Validation: 197 unit tests pass;
npm run build:lib,npm run checktype, ESLint on the changed files, andgit diff --checkpass. Browser visual tests were not run.Merging options