AAE-42904 Escape html in evaluated fields and variables for rich-text display widget (#11718)

This commit is contained in:
David Olson
2026-03-09 10:25:55 -05:00
committed by GitHub
parent c428f547bc
commit 68b1b98c83
5 changed files with 48 additions and 5 deletions
@@ -137,13 +137,15 @@ describe('DisplayRichTextWidgetComponent', () => {
});
it('should sanitize unsafe HTML', async () => {
mockRichTextParserService.parse.and.returnValue('<img src="x" onerror="alert(\'XSS\')">');
widget.field = mockUnsafeFormField;
fixture.detectChanges();
await fixture.whenStable();
const parsedHtmlEl = debugEl.query(By.css(cssSelector.parsedHTML));
expect(parsedHtmlEl.nativeElement.innerHTML.includes('<img src="x" onerror="alert(\'XSS\')">')).toBe(false);
expect(parsedHtmlEl.nativeElement.innerHTML.includes('img src="x"')).toBe(true);
expect(parsedHtmlEl.nativeElement.innerHTML.includes('onerror')).toBe(false);
});
describe('expression evaluation', () => {
@@ -90,7 +90,7 @@ export class DisplayRichTextWidgetComponent extends BaseDisplayTextWidgetCompone
private applyExpressionsToBlocks(value: any): void {
for (const block of value.blocks) {
block.data.text = this.resolveExpressions(block.data.text);
block.data.text = this.resolveExpressions(block.data.text, true);
}
this.field.value = value;
}