Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1e6b068

Browse files
committed
fixup! feat($compile): add support for arbitrary property and event bindings
1 parent 45fe38b commit 1e6b068

File tree

1 file changed

+1
-43
lines changed

1 file changed

+1
-43
lines changed

test/ng/compileSpec.js

+1-43
Original file line numberDiff line numberDiff line change
@@ -12416,30 +12416,6 @@ describe('$compile', function() {
1241612416
expect(element.prop('src')).toEqual('someuntrustedthing:foo();');
1241712417
}));
1241812418

12419-
it('should sanitize concatenated values even if they are trusted', inject(function($rootScope, $compile, $sce) {
12420-
element = $compile('<img ng-prop-src="testUrl + \'ponies\'"></img>')($rootScope);
12421-
$rootScope.testUrl = $sce.trustAsUrl('untrusted:foo();');
12422-
$rootScope.$digest();
12423-
expect(element.prop('src')).toEqual('unsafe:untrusted:foo();ponies');
12424-
12425-
element = $compile('<img ng-prop-src="\'http://\' + testUrl2"></img>')($rootScope);
12426-
$rootScope.testUrl2 = $sce.trustAsUrl('xyz;');
12427-
$rootScope.$digest();
12428-
expect(element.prop('src')).toEqual('http://xyz%3B/');
12429-
12430-
element = $compile('<img ng-prop-src="testUrl3 + testUrl3"></img>')($rootScope);
12431-
$rootScope.testUrl3 = $sce.trustAsUrl('untrusted:foo();');
12432-
$rootScope.$digest();
12433-
expect(element.prop('src')).toEqual('unsafe:untrusted:foo();untrusted:foo();');
12434-
}));
12435-
12436-
it('should not sanitize other properties', inject(function($compile, $rootScope) {
12437-
element = $compile('<img ng-prop-title="testUrl"></img>')($rootScope);
12438-
$rootScope.testUrl = 'javascript:doEvilStuff()';
12439-
$rootScope.$apply();
12440-
expect(element.prop('title')).toBe('javascript:doEvilStuff()');
12441-
}));
12442-
1244312419
it('should use $$sanitizeUri', function() {
1244412420
var $$sanitizeUri = jasmine.createSpy('$$sanitizeUri');
1244512421
module(function($provide) {
@@ -12456,24 +12432,6 @@ describe('$compile', function() {
1245612432
});
1245712433
});
1245812434

12459-
it('should use $$sanitizeUri on concatenated trusted values', function() {
12460-
var $$sanitizeUri = jasmine.createSpy('$$sanitizeUri').and.returnValue('someSanitizedUrl');
12461-
module(function($provide) {
12462-
$provide.value('$$sanitizeUri', $$sanitizeUri);
12463-
});
12464-
inject(function($compile, $rootScope, $sce) {
12465-
element = $compile('<img ng-prop-src="testUrl + \'ponies\'"></img>')($rootScope);
12466-
$rootScope.testUrl = $sce.trustAsUrl('javascript:foo();');
12467-
$rootScope.$digest();
12468-
expect(element.prop('src')).toMatch(/^http:\/\/.*\/someSanitizedUrl$/);
12469-
12470-
element = $compile('<img ng-prop-src="\'http://\' + testUrl"></img>')($rootScope);
12471-
$rootScope.testUrl = $sce.trustAsUrl('xyz');
12472-
$rootScope.$digest();
12473-
expect(element.prop('src')).toMatch(/^http:\/\/.*\/someSanitizedUrl$/);
12474-
});
12475-
});
12476-
1247712435
it('should not use $$sanitizeUri with trusted values', function() {
1247812436
var $$sanitizeUri = jasmine.createSpy('$$sanitizeUri').and.throwError('Should not have been called');
1247912437
module(function($provide) {
@@ -12558,7 +12516,7 @@ describe('$compile', function() {
1255812516
});
1255912517

1256012518
it('should sanitize all uris in srcset', inject(function($rootScope, $compile) {
12561-
element = $compile('<img srcset="{{testUrl}}"></img>')($rootScope);
12519+
element = $compile('<img ng-prop-srcset="testUrl"></img>')($rootScope);
1256212520
var testSet = {
1256312521
'http://example.com/image.png':'http://example.com/image.png',
1256412522
' http://example.com/image.png':'http://example.com/image.png',

0 commit comments

Comments
 (0)