Skip to content

[FIX] sap.ui.core.format.ListFormat: keep '$' in values literal#4452

Open
martindglaser wants to merge 1 commit into
UI5:masterfrom
martindglaser:fix/listformat-escape-replacement
Open

[FIX] sap.ui.core.format.ListFormat: keep '$' in values literal#4452
martindglaser wants to merge 1 commit into
UI5:masterfrom
martindglaser:fix/listformat-escape-replacement

Conversation

@martindglaser

Copy link
Copy Markdown
Contributor

Summary

sap.ui.core.format.ListFormat#format builds its result with String.prototype.replace and passes the list values directly as the replacement string. $ sequences in a value ($&, $$, $', $`) are therefore interpreted as special replacement patterns and corrupt the output.

Examples (de-DE):

  • format(["a$'b", "B"]) → garbled text instead of "a$'b und B"
  • format(["100$$", "B"])"100$ und B" instead of "100$$ und B"
  • format(["Total: $&", "B"])"Total: {0} und B" instead of "Total: $& und B"

This affects any list whose values may contain $ (prices, titles, user-entered text).

Fix

Insert the values through a replacement function (asReplacement) so they are taken literally, at every dynamic-replacement site in format. No API/behavior change for values without $.

Testing

Added a regression test to ListFormat.qunit.js covering $&, $$ and $' in the exact-count, start and end elements. The test fails before the fix and passes after. Verified in Node as well.

ListFormat#format built the result with String.prototype.replace and passed the
list values directly as the replacement string. '$' sequences in a value (e.g.
"$&", "$$", "$'", "$`") were therefore interpreted as special replacement
patterns and corrupted the output, e.g. format(["a$'b", "B"]) returned garbled
text instead of "a$'b und B".

Insert the values via a replacement function so they are taken literally, and
add a regression test.
@kgogov

kgogov commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Hello @martindglaser,

Thank you for creating this PR — much appreciated! 🙌

I've created internal incident DINC0976841 to track this. Colleagues responsible for this module will look it up soon, and I'll keep the status updated here.

Regards,
Konstantin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants