Skip to content

Commit

Permalink
changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Jul 11, 2020
1 parent 26d5719 commit 2a6d7e7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 19.6.0

- fix prototype pollution
- introduce new interpolation option skipOnVariables [1483](https://github.com/i18next/i18next/pull/1483)

### 19.5.6

- fix local usage of nsSeparator option
Expand Down
32 changes: 25 additions & 7 deletions i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,16 @@
}
function deepExtend(target, source, overwrite) {
for (var prop in source) {
if (prop in target) {
if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
if (overwrite) target[prop] = source[prop];
if (prop !== '__proto__') {
if (prop in target) {
if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
if (overwrite) target[prop] = source[prop];
} else {
deepExtend(target[prop], source[prop], overwrite);
}
} else {
deepExtend(target[prop], source[prop], overwrite);
target[prop] = source[prop];
}
} else {
target[prop] = source[prop];
}
}

Expand Down Expand Up @@ -802,9 +804,24 @@
if (options.interpolation) this.interpolator.init(_objectSpread({}, options, {
interpolation: _objectSpread({}, this.options.interpolation, options.interpolation)
}));
var skipOnVariables = options.interpolation && options.interpolation.skipOnVariables || this.options.interpolation.skipOnVariables;
var nestBef;

if (skipOnVariables) {
var nb = res.match(this.interpolator.nestingRegexp);
nestBef = nb && nb.length;
}

var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
if (this.options.interpolation.defaultVariables) data = _objectSpread({}, this.options.interpolation.defaultVariables, data);
res = this.interpolator.interpolate(res, data, options.lng || this.language, options);

if (skipOnVariables) {
var na = res.match(this.interpolator.nestingRegexp);
var nestAft = na && na.length;
if (nestBef < nestAft) options.nest = false;
}

if (options.nest !== false) res = this.interpolator.nest(res, function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
Expand Down Expand Up @@ -1839,7 +1856,8 @@
nestingPrefix: '$t(',
nestingSuffix: ')',
nestingOptionsSeparator: ',',
maxReplaces: 1000
maxReplaces: 1000,
skipOnVariables: false
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion i18next.min.js

Large diffs are not rendered by default.

0 comments on commit 2a6d7e7

Please sign in to comment.