Skip to content

fix(icon): icons will load when content security policies are enabled #1141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 8, 2022

Conversation

sean-perkins
Copy link
Contributor

Background

When content security policies (CSP) are enabled, the usage of <ion-icon icon={icon}> fails to load, due to the url being a data: uri.

e.g.:

With a CSP of:

default-src 'none'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com/*; img-src 'self'; connect-src 'self'; font-src https://fonts.gstatic.com/*'

What's new

  • Icons with a data url will be parsed using the DOMParser, allowing the asset to safely load
  • <ion-icon icon={icon}> will render when a CSP is enabled.

@@ -22,6 +22,14 @@ export const config: Config = {
src: './components/test/*.svg',
dest: './assets/',
},
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change was to allow the local dev server to have more than the single index.html test template. Is there another way to accomplish this or is this the recommended path?

@sean-perkins
Copy link
Contributor Author

If Liam can create a pre-release build, that would be awesome. I'm confident in these changes as they relate to the ionicons repo, but would like to do additional verification in Framework + cut a dev-build there to have CS/customer also verify.

@sean-perkins sean-perkins marked this pull request as ready for review October 31, 2022 18:21
@sean-perkins
Copy link
Contributor Author

Validated that this fixes the reported bug:

Framework dev-build: 6.3.5-dev.11667495782.100cdb2c
Reproduction: https://github.com/dtarnawsky/cs-back-button-csp

Back button icon loads on the dev-build without an error. We have other CSP violations in some of our styles that I've reported in the JIRA task.

Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

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

Great job!

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.

2 participants