v1.18.x
barisusakli 9 years ago
parent edba2dda21
commit 3567f2ad55

@ -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(/&#37;/g, '%').replace(/&#44;/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, '&#37;').replace(/,/g, '&#44;');
var key = "[[topic:composer.replying_to, " + title + "]]";
translator.translate(key, function(translated) {
assert.strictEqual(translated, 'Replying to Test 1, 2, 3 % salmon');
done();
});
});
});
});

Loading…
Cancel
Save