Skip to content

refactor(icon): bind icon as CSS mask#1519

Draft
spike-rabbit wants to merge 1 commit intomainfrom
refactor/icons/bind-as-css-mask
Draft

refactor(icon): bind icon as CSS mask#1519
spike-rabbit wants to merge 1 commit intomainfrom
refactor/icons/bind-as-css-mask

Conversation

@spike-rabbit
Copy link
Member

This avoids potential XSS risks, by injecting the icon only as CSS mask-image.


Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great step forward in improving security by removing innerHTML and DomSanitizer when rendering icons, opting for a safer CSS mask approach. The changes are well-implemented across the affected components and services. I've identified a bug where icons containing double quotes in their SVG data might not render correctly, and I've provided suggestions to fix this. Overall, excellent work on this refactoring.

}
return domSanitizer.bypassSecurityTrustHtml(parsed[1]);
};
const parseDataSvgIcon = (icon: string): string => `url("${icon}")`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current implementation of parseDataSvgIcon does not handle double quotes within the icon string, which can lead to broken image URLs. If an icon's SVG data contains a double quote, it will prematurely terminate the string within the url() function, causing the icon to fail to render. To fix this, you should escape any double quotes within the icon string.

Suggested change
const parseDataSvgIcon = (icon: string): string => `url("${icon}")`;
const parseDataSvgIcon = (icon: string): string => `url("${icon.replace(/"/g, '\\"')}")`;

return '';
}
return this.domSanitizer.bypassSecurityTrustHtml(parsed[1]);
return `url("${icon}")`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current implementation of parseDataSvgIcon does not handle double quotes within the icon string, which can lead to broken image URLs. If an icon's SVG data contains a double quote, it will prematurely terminate the string within the url() function, causing the icon to fail to render. To fix this, you should escape any double quotes within the icon string.

Suggested change
return `url("${icon}")`;
return `url("${icon.replace(/"/g, '\\"')}")`;

@spike-rabbit spike-rabbit force-pushed the refactor/icons/bind-as-css-mask branch from 23cc34f to 93d24fd Compare February 13, 2026 10:23
This avoids potential XSS risks, by injecting the icon only as CSS mask-image.
@spike-rabbit spike-rabbit force-pushed the refactor/icons/bind-as-css-mask branch from 93d24fd to 03207c6 Compare February 13, 2026 10:29
@github-actions
Copy link

Code Coverage

@github-actions
Copy link

@spike-rabbit
Copy link
Member Author

@dr-itz do you have any opinion here? I don't remember, why we did not implement it that way in the beginning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant