From 5ab0534164487ad1a6aeca376b8102d7217aeb9d Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Wed, 22 Jun 2016 18:14:50 -0700 Subject: [PATCH] test(security): Ensure xlink:href is not bindable. 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 #9510. --- .../core/test/linker/security_integration_spec.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/@angular/core/test/linker/security_integration_spec.ts b/modules/@angular/core/test/linker/security_integration_spec.ts index 1b7ab43223..bda6fdf177 100644 --- a/modules/@angular/core/test/linker/security_integration_spec.ts +++ b/modules/@angular/core/test/linker/security_integration_spec.ts @@ -194,6 +194,19 @@ function declareTests({useJit}: {useJit: boolean}) { }); }); + itAsync( + 'should escape unsafe SVG attributes', + (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { + let tpl = `Text`; + 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) => {