Skip to content

Commit

Permalink
test(security): Ensure xlink:href is not bindable.
Browse files Browse the repository at this point in the history
The DOM schema does not allow binding any properties to dangerous SVG
attributes/properties. This change adds a smoke test to verify that
behaviour, by testing that `xlink:href` (a sample dangerous property)
is not bindable.

Fixes angular#9510.
  • Loading branch information
mprobst committed Jun 23, 2016
1 parent 5150344 commit 5ab0534
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions modules/@angular/core/test/linker/security_integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ function declareTests({useJit}: {useJit: boolean}) {
});
});

itAsync(
'should escape unsafe SVG attributes',
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
let tpl = `<svg:circle [xlink:href]="ctxProp">Text</svg:circle>`;
tcb = tcb.overrideView(
SecuredComponent, new ViewMetadata({template: tpl, directives: []}));
PromiseWrapper.catchError(tcb.createAsync(SecuredComponent), (e) => {
expect(e.message).toContain(`Can't bind to 'xlink:href'`);
async.done();
return null;
});
});

itAsync(
'should escape unsafe HTML values',
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
Expand Down

0 comments on commit 5ab0534

Please sign in to comment.