Skip to content
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

Modal should not violate CSP style-src 'none' #738

Conversation

jelhan
Copy link
Contributor

@jelhan jelhan commented Jan 6, 2019

Binding style attribute causes a Content-Security-Policy violation unless style-src allows 'unsafe-inline'. To avoid this CSS Object Model (CSSOM) must be used.

CSP violation is triggered by glimmer executing element.setAttribute('style', value).

This has been discussed here without coming up with a better solution: https://discuss.emberjs.com/t/binding-style-attribute-and-content-security-policy-best-practice/10921

Binding style attribute causes a Content-Security-Policy violation unless
`style-src` allows `'unsafe-inline'`. To avoid this CSS Object Model (CSSOM)
must be used.

CSP violation is triggered by glimmer executing `element.setAttribute('style', value)`.

This has been discussed here without coming up with a better solution:
https://discuss.emberjs.com/t/binding-style-attribute-and-content-security-policy-best-practice/10921
@@ -201,6 +194,11 @@ export default Component.extend({
// directly to the element
this.element.onclick = bind(this, this._click);
this.getOrSetTitleId();
this.updateStyles();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could not use didReceiveAttrs cause that one is executed before element is insert into DOM.

Copy link
Contributor

@simonihmig simonihmig left a comment

Choose a reason for hiding this comment

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

Nice!

@simonihmig simonihmig changed the title fix(Modal): should not violate CSP style-src 'none' Modal should not violate CSP style-src 'none' Jan 9, 2019
@simonihmig simonihmig added the bug label Jan 9, 2019
@simonihmig simonihmig merged commit 2782eea into ember-bootstrap:master Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants