[FIX] sap.ui.core.format.ListFormat: keep '$' in values literal#4452
Open
martindglaser wants to merge 1 commit into
Open
[FIX] sap.ui.core.format.ListFormat: keep '$' in values literal#4452martindglaser wants to merge 1 commit into
martindglaser wants to merge 1 commit into
Conversation
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.
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, |
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.
Summary
sap.ui.core.format.ListFormat#formatbuilds its result withString.prototype.replaceand 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 informat. No API/behavior change for values without$.Testing
Added a regression test to
ListFormat.qunit.jscovering$&,$$and$'in the exact-count, start and end elements. The test fails before the fix and passes after. Verified in Node as well.