This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
escapeParameters sanitize strategy transform booleans to string #1747
Comments
There is simple fix for the problem: we need to change var mapInterpolationParameters = function (value, iteratee, stack) {
// simple check if value is Boolean
if (value === true || value === false) {
return value;
}
// following is the same as before
if (angular.isDate(value)) {
return value;
} else 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) {
/* Skipping function properties. */
if (angular.isFunction(propertyValue)) {
return;
}
result[propertyKey] = mapInterpolationParameters(propertyValue, iteratee, stack);
});
stack.splice(-1, 1); // remove last
return result;
} else if (angular.isNumber(value)) {
return value;
} else if (!angular.isUndefined(value) && value !== null) {
return iteratee(value);
} else {
return value;
}
}; But, this way will work wrong with |
afitiskin
added a commit
to afitiskin/angular-translate
that referenced
this issue
Jun 14, 2017
When using `$translateSanitizationProvider` with `escapeParameters` or `sanitizeParameters` strategy boolean values transformed to strings, e.g. `false` becomes `"false"`. With this fix boolean values are not transformed. Closes angular-translate#1747
afitiskin
added a commit
to afitiskin/angular-translate
that referenced
this issue
Jun 22, 2017
Update `$translateSanitizationProvider` specs to test truthy boolean values Relates angular-translate#1747
knalli
pushed a commit
that referenced
this issue
Jun 22, 2017
When using `$translateSanitizationProvider` with `escapeParameters` or `sanitizeParameters` strategy boolean values transformed to strings, e.g. `false` becomes `"false"`. With this fix boolean values are not transformed. Closes #1747
knalli
pushed a commit
that referenced
this issue
Jun 22, 2017
Update `$translateSanitizationProvider` specs to test truthy boolean values Relates #1747
PR is merged, so I think we can close the issue |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Subject of the issue
When using
escapeParameters
sanitize strategy all boolean values are transformed to strings. So if you pass following object:to
angular-translate-values
, it will be transformed to:Your environment
2.15.1
1.6.4
Steps to reproduce
escapeParameters
strategy:translate-values
totranslate
directive in template:SOME_KEY
in dictionary:SOME_KEY: "{{ data | json }}"
Expected behaviour
Booleans should not be converted to strings. As I see in source code of
mapInterpolationParameters
(in/src/service/sanitization.js
) there are special conditions for dates, objects, arrays and numbers, but booleans are missed.Actual behaviour
Currently all booleans are converted to strings, so filters in translations can work wrong, for example:
The text was updated successfully, but these errors were encountered: