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

Commit

Permalink
fix(service): treat date param as-is (no sanitize/escape)
Browse files Browse the repository at this point in the history
Fixes #1560
  • Loading branch information
knalli committed Aug 21, 2016
1 parent ac85768 commit ab1ecce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/service/sanitization.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ function $translateSanitizationProvider () {
};

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

if (!stack) {
Expand Down
13 changes: 13 additions & 0 deletions test/unit/service/default-interpolation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ describe('pascalprecht.translate', function () {
expect($translateDefaultInterpolation.interpolate(text, params)).toBe(sanitizedText);
expect($translateSanitization.sanitize).toHaveBeenCalledWith(interpolatedText, 'text');
}));

it('should ignore a date param', inject(function ($translateSanitization) {
var text = 'Day is: {{day | date:"dd.MM.yyyy"}}';
var params = {
day: new Date('2016-08-21')
};
var sanitizedText = 'Day is: 21.08.2016';

spyOn($translateSanitization, 'sanitize').and.callThrough();
$translateSanitization.useStrategy('escapeParameters');
expect($translateDefaultInterpolation.interpolate(text, params)).toBe(sanitizedText);
//expect()
}));
});

describe('$translateDefaultInterpolation#useSanitizeValueStrategy', function () {
Expand Down

0 comments on commit ab1ecce

Please sign in to comment.