Skip to content

Commit 5a4846e

Browse files
committed
Make it return safe html
1 parent d398fa1 commit 5a4846e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/diff.filter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
angular.module('diff', [])
4-
.filter('diff', function () {
4+
.filter('diff', function ($sce) {
55

66
/*
77
* Javascript Diff Algorithm
@@ -173,6 +173,6 @@ angular.module('diff', [])
173173

174174
// Actual filter
175175
return function(input, match) {
176-
return diffString(input, match);
176+
return $sce.trustAsHtml(diffString(input, match));
177177
};
178178
});

tests/diff.filter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ describe('filter', function() {
99
it('should convert a string to the diff value with another string', inject(function(diffFilter) {
1010
expect(diffFilter(
1111
'The red brown fox jumped over the rolling log.',
12-
'The brown spotted fox leaped over the rolling log')).toBe(
12+
'The brown spotted fox leaped over the rolling log')
13+
.$$unwrapTrustedValue()).toBe(
1314
' The <del>red </del> brown <ins>spotted </ins> fox <del>jumped </del><ins>leaped </ins> over the rolling <del>log.\n</del><ins>log\n</ins>');
1415
}));
1516
});

0 commit comments

Comments
 (0)