mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
Better XSS Fix (#12483)
* Revert "fix(test): adjust expectations" This reverts commit205436d5b1. * Revert "fix(escaping): global inoffensive apostrophe" This reverts commit2b8f94b244. * change <%- to <%= * fix interpolation only where necessary * remove unused variable
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import isString from 'lodash/isString';
|
||||
import clone from 'lodash/clone';
|
||||
import forEach from 'lodash/forEach';
|
||||
import template from 'lodash/template';
|
||||
|
||||
const i18n = {
|
||||
@@ -37,16 +36,9 @@ function t (stringName) {
|
||||
|
||||
const clonedVars = clone(vars) || {};
|
||||
|
||||
forEach(clonedVars, (val, key) => {
|
||||
if (typeof clonedVars[key] === 'string') {
|
||||
clonedVars[key] = clonedVars[key].replace(/'/g, '’');
|
||||
}
|
||||
});
|
||||
|
||||
clonedVars.locale = locale;
|
||||
|
||||
if (string) {
|
||||
string = string.replace(/'/g, '’');
|
||||
try {
|
||||
return template(string)(clonedVars);
|
||||
} catch (_error) {
|
||||
|
||||
Reference in New Issue
Block a user