Drupal.formatString() doesn't properly replace all the placeholders. This bug was introduced in issue #2182265.
Steps to reproduce:
Try to quick-edit any content, it will show an error ("Could not load the form for Body, either due to a website problem or a network connection problem.
Please try again.").
Small test example is to write Drupal.stringReplace("/x/!aa/!b", {"!aa":1, "!b":2}, null);
in webinspector.
Expected result: "/x/1/2"
Actual result: "/x/1/!b"
Problem happens because Drupal.stringReplace() splits the input string into two parts and calls itself recursively with the same keys object. Each such iteration removes one element from the remaining keys array, even if this key isn't found in this part of the string. Following recursions are using one less keys element, which is why they cannot replace some of the placeholders in the original string.
Attached patch fixes the problem by doing the recursion with the copy of the keys array instead.
/Andrejs
Comment | File | Size | Author |
---|---|---|---|
locale-js-plural--1-D8.patch | 492 bytes | andrejsmuzikovs | |
Comments
Comment #1
nod_That makes sense, thanks.
Comment #2
catchCommitted/pushed to 8.x, thanks!
Comment #3
SweetchuckSorry for this mistake, and @andrejsmuzikovs thank you for the fix.
Comment #4
andrejsmuzikovs CreditAttribution: andrejsmuzikovs commentedNo problems, and thanks! My first contribution :)
/Andrejs