Skip to content

Commit

Permalink
prepare new version
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Jul 15, 2020
1 parent 655bece commit 7d8e9e6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 48 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
### 19.6.1

- extend interpolation option skipOnVariables [1488](https://github.com/i18next/i18next/pull/1488)
- typescript: Change bindStore to bindI18nStore in ReactOptions type and update default values [1489](https://github.com/i18next/i18next/pull/1489)

### 19.6.0

- fix prototype pollution
Expand Down
82 changes: 35 additions & 47 deletions i18next.js
Expand Up @@ -1434,60 +1434,48 @@

this.resetRegExp();
var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
replaces = 0;

while (match = this.regexpUnescape.exec(str)) {
value = handleFormat(match[1].trim());

if (value === undefined) {
if (typeof missingInterpolationHandler === 'function') {
var temp = missingInterpolationHandler(str, match, options);
value = typeof temp === 'string' ? temp : '';
} else {
this.logger.warn("missed to pass in variable ".concat(match[1], " for interpolating ").concat(str));
value = '';
}
} else if (typeof value !== 'string' && !this.useRawValueToEscape) {
value = makeString(value);
var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables || this.options.interpolation.skipOnVariables;
var todos = [{
regex: this.regexpUnescape,
safeValue: function safeValue(val) {
return regexSafe(val);
}

str = str.replace(match[0], regexSafe(value));
this.regexpUnescape.lastIndex = 0;
replaces++;

if (replaces >= this.maxReplaces) {
break;
}, {
regex: this.regexp,
safeValue: function safeValue(val) {
return _this.escapeValue ? regexSafe(_this.escape(val)) : regexSafe(val);
}
}

replaces = 0;

while (match = this.regexp.exec(str)) {
value = handleFormat(match[1].trim());

if (value === undefined) {
if (typeof missingInterpolationHandler === 'function') {
var _temp = missingInterpolationHandler(str, match, options);
}];
todos.forEach(function (todo) {
replaces = 0;

while (match = todo.regex.exec(str)) {
value = handleFormat(match[1].trim());

if (value === undefined) {
if (typeof missingInterpolationHandler === 'function') {
var temp = missingInterpolationHandler(str, match, options);
value = typeof temp === 'string' ? temp : '';
} else if (skipOnVariables) {
value = match[0];
} else {
_this.logger.warn("missed to pass in variable ".concat(match[1], " for interpolating ").concat(str));

value = typeof _temp === 'string' ? _temp : '';
} else {
this.logger.warn("missed to pass in variable ".concat(match[1], " for interpolating ").concat(str));
value = '';
value = '';
}
} else if (typeof value !== 'string' && !_this.useRawValueToEscape) {
value = makeString(value);
}
} else if (typeof value !== 'string' && !this.useRawValueToEscape) {
value = makeString(value);
}

value = this.escapeValue ? regexSafe(this.escape(value)) : regexSafe(value);
str = str.replace(match[0], value);
this.regexp.lastIndex = 0;
replaces++;
str = str.replace(match[0], todo.safeValue(value));
todo.regex.lastIndex = 0;
replaces++;

if (replaces >= this.maxReplaces) {
break;
if (replaces >= _this.maxReplaces) {
break;
}
}
}

});
return str;
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion i18next.min.js

Large diffs are not rendered by default.

0 comments on commit 7d8e9e6

Please sign in to comment.