From 4c53e507574a698153f65cc79fb090c579e41fbe Mon Sep 17 00:00:00 2001
From: SkyZeroZx <73321943+SkyZeroZx@users.noreply.github.com>
Date: Sun, 10 May 2026 23:42:17 -0500
Subject: [PATCH 1/2] fix(core): sanitize text bindings on SVG `,
+ changeDetection: ChangeDetectionStrategy.Eager,
+ })
+ class TestCmp {
+ code = '/* xss */';
+ }
+
+ expect(() => {
+ const fixture = TestBed.createComponent(TestCmp);
+ fixture.detectChanges();
+ }).toThrowError(/NG0905/);
+ });
+
+ it(`should error when '${propName}' is bound on an SVG ',
+ imports: [ScriptHostDir],
+ changeDetection: ChangeDetectionStrategy.Eager,
+ })
+ class TestCmp {}
+
+ expect(() => {
+ const fixture = TestBed.createComponent(TestCmp);
+ fixture.detectChanges();
+ }).toThrowError(/NG0905/);
+ });
+ }
+
+ it('should allow values trusted via DomSanitizer.bypassSecurityTrustScript', () => {
+ @Component({
+ template: '',
+ changeDetection: ChangeDetectionStrategy.Eager,
+ })
+ class TestCmp {
+ private readonly sanitizer = inject(DomSanitizer);
+ code = this.sanitizer.bypassSecurityTrustScript('/* trusted */');
+ }
+
+ const fixture = TestBed.createComponent(TestCmp);
+ fixture.detectChanges();
+ expect(fixture.nativeElement.querySelector('script').textContent).toContain('/* trusted */');
+ });
+});
diff --git a/packages/core/test/sanitization/sanitization_spec.ts b/packages/core/test/sanitization/sanitization_spec.ts
index bdfbc3882666..8e8243bc0f53 100644
--- a/packages/core/test/sanitization/sanitization_spec.ts
+++ b/packages/core/test/sanitization/sanitization_spec.ts
@@ -118,7 +118,7 @@ describe('sanitization', () => {
[SecurityContext.RESOURCE_URL, ɵɵsanitizeResourceUrl],
]);
Object.entries(schema).forEach(([key, context]) => {
- if (context === SecurityContext.URL || SecurityContext.RESOURCE_URL) {
+ if (context === SecurityContext.URL || context === SecurityContext.RESOURCE_URL) {
const [tag, prop] = key.split('|');
const contexts = contextsByProp.get(prop) || new Set();
contexts.add(context);
From a3362a11aea7c1a204e0932e549c72bd657a337a Mon Sep 17 00:00:00 2001
From: SkyZeroZx <73321943+SkyZeroZx@users.noreply.github.com>
Date: Mon, 11 May 2026 10:42:58 -0500
Subject: [PATCH 2/2] fixup! fix(core): sanitize text bindings on SVG