mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-19 23:40:54 +02:00
closes #4208
This commit is contained in:
@@ -164,7 +164,7 @@
|
||||
if (!count) {
|
||||
return callback(text);
|
||||
}
|
||||
|
||||
|
||||
if (S === null) { // browser environment and S not yet initialized
|
||||
// we need to wait for async require call
|
||||
stringDefer.then(function () { translateKeys(keys, text, language, callback); });
|
||||
@@ -205,6 +205,10 @@
|
||||
if (value) {
|
||||
var variable;
|
||||
for (var i = 1, ii = variables.length; i < ii; i++) {
|
||||
|
||||
// see https://github.com/NodeBB/NodeBB/issues/1951
|
||||
variables[i] = variables[i].replace(/%/g, '%').replace(/,/g, ',');
|
||||
|
||||
variable = S(variables[i]).chompRight(']]').collapseWhitespace().escapeHTML().s;
|
||||
value = value.replace('%' + i, variable);
|
||||
}
|
||||
|
||||
@@ -85,5 +85,15 @@ describe('Translator', function(){
|
||||
});
|
||||
});
|
||||
|
||||
it('should properly escape % and ,', function(done) {
|
||||
var title = 'Test 1, 2, 3 % salmon';
|
||||
title = title.replace(/%/g, '%').replace(/,/g, ',');
|
||||
var key = "[[topic:composer.replying_to, " + title + "]]";
|
||||
translator.translate(key, function(translated) {
|
||||
assert.strictEqual(translated, 'Replying to Test 1, 2, 3 % salmon');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user