@fkui/i18next-translate 6.43.0 → 6.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js
CHANGED
|
@@ -2297,6 +2297,7 @@ class Logger {
|
|
|
2297
2297
|
}
|
|
2298
2298
|
forward(args, lvl, prefix, debugOnly) {
|
|
2299
2299
|
if (debugOnly && !this.debug) return null;
|
|
2300
|
+
args = args.map(a => isString(a) ? a.replace(/[\r\n\x00-\x1F\x7F]/g, ' ') : a);
|
|
2300
2301
|
if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
|
|
2301
2302
|
return this.logger[lvl](args);
|
|
2302
2303
|
}
|
|
@@ -3202,8 +3203,8 @@ class Interpolator {
|
|
|
3202
3203
|
this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || '{{';
|
|
3203
3204
|
this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || '}}';
|
|
3204
3205
|
this.formatSeparator = formatSeparator || ',';
|
|
3205
|
-
this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix
|
|
3206
|
-
this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix
|
|
3206
|
+
this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix ? regexEscape(unescapePrefix) : '-';
|
|
3207
|
+
this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix ? regexEscape(unescapeSuffix) : '';
|
|
3207
3208
|
this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape('$t(');
|
|
3208
3209
|
this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(')');
|
|
3209
3210
|
this.nestingOptionsSeparator = nestingOptionsSeparator || ',';
|
|
@@ -3250,6 +3251,9 @@ class Interpolator {
|
|
|
3250
3251
|
});
|
|
3251
3252
|
};
|
|
3252
3253
|
this.resetRegExp();
|
|
3254
|
+
if (!this.escapeValue && typeof str === 'string' && /\$t\([^)]*\{[^}]*\{\{/.test(str)) {
|
|
3255
|
+
this.logger.warn('nesting options string contains interpolated variables with escapeValue: false — ' + 'if any of those values are attacker-controlled they can inject additional ' + 'nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing ' + 'it to t(), or keep escapeValue: true.');
|
|
3256
|
+
}
|
|
3253
3257
|
const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
|
3254
3258
|
const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
3255
3259
|
const todos = [{
|
|
@@ -3928,7 +3932,7 @@ class I18n extends EventEmitter {
|
|
|
3928
3932
|
deferred.resolve(t);
|
|
3929
3933
|
callback(err, t);
|
|
3930
3934
|
};
|
|
3931
|
-
if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
|
|
3935
|
+
if ((this.languages || this.isLanguageChangingTo) && !this.isInitialized) return finish(null, this.t.bind(this));
|
|
3932
3936
|
this.changeLanguage(this.options.lng, finish);
|
|
3933
3937
|
};
|
|
3934
3938
|
if (this.options.resources || !this.options.initAsync) {
|