Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
fix(service): avoid call stack size error, print proper message
Browse files Browse the repository at this point in the history
Relates #1396
  • Loading branch information
knalli committed Feb 13, 2016
1 parent 40ad523 commit 73ea6e3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/service/sanitization.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,23 @@ function $translateSanitizationProvider () {
return $sanitize(value);
};

var mapInterpolationParameters = function (value, iteratee) {
var mapInterpolationParameters = function (value, iteratee, stack) {
if (angular.isObject(value)) {
var result = angular.isArray(value) ? [] : {};

if (!stack) {
stack = [];
} else {
if (stack.indexOf(value) > -1) {
throw new Error('pascalprecht.translate.$translateSanitization: Error cannot interpolate parameter due recursive object');
}
}

stack.push(value);
angular.forEach(value, function (propertyValue, propertyKey) {
result[propertyKey] = mapInterpolationParameters(propertyValue, iteratee);
result[propertyKey] = mapInterpolationParameters(propertyValue, iteratee, stack);
});
stack.splice(-1, 1); // remove last

return result;
} else if (angular.isNumber(value)) {
Expand Down

0 comments on commit 73ea6e3

Please sign in to comment.