Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit 4124965

Browse files
committed
fix bidi isolation mark wrapping in locale.translation
address #4396 (comment) Auditors: @aekeus Test Plan: 1. go to ledger panel, save recovery keys 2. verify that opening the saved file in the browser does not show non-ascii characters
1 parent ac27858 commit 4124965

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/locale.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,19 @@ var ctx = null
230230
var translations = {}
231231
var lang = 'en-US'
232232

233+
// todo: FSI/PDI stripping can probably be replaced once
234+
// https://github.com/l20n/l20n.js/commit/2fea50bf43c43a8e930a519a37f0f64f3626e885
235+
// is released
236+
const FSI = '\u2068'
237+
const PDI = '\u2069'
238+
233239
// Return a translate token from cache or a placeholder
234240
// indicating that no translation is available
235241
exports.translation = function (token, replacements = {}) {
236242
if (translations[token]) {
237243
let returnVal = translations[token]
238244
for (var key in replacements) {
239-
returnVal = returnVal.replace(new RegExp('{{\\s*' + key + '\\s*}}'), replacements[key])
245+
returnVal = returnVal.replace(new RegExp(FSI + '{{\\s*' + key + '\\s*}}' + PDI), replacements[key])
240246
}
241247
return returnVal
242248
} else {

0 commit comments

Comments
 (0)