Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Avoid inline execution of javascript in choices template. #1182

Merged
merged 1 commit into from
Nov 1, 2015
Merged

Avoid inline execution of javascript in choices template. #1182

merged 1 commit into from
Nov 1, 2015

Conversation

Sjors
Copy link
Contributor

@Sjors Sjors commented Sep 8, 2015

If a server sets the content-security-policy header to script-src 'self' 'unsafe-inline'; all works well, but without unsafe-unline, the browser will throw an error: Refused to execute JavaScript URL because it violates the following Content Security Policy directive:.

There is no stack trace, but it turns out this is caused by href="javascript:void(0)" in the choices template.

Pull request #395 proposed removing that piece Javascript altogether, but apparently there were side effects.

I'm replacing it with ng-click="$event.preventDefault()", based on a similar fix in the ui.bootstrap project. This makes the CSP error go away.

All tests pass. I tried all examples in Safari and couldn't see anything obviously wrong, but I'm not sure what to look for.

Sjors added a commit to blockchain/My-Wallet-V3-Frontend that referenced this pull request Sep 8, 2015
@Sjors
Copy link
Contributor Author

Sjors commented Oct 27, 2015

Is there something I should improve in this PR to make it more likely to get merged?

dimirc added a commit that referenced this pull request Nov 1, 2015
Avoid inline execution of javascript in choices template.
@dimirc dimirc merged commit 4467b82 into angular-ui:master Nov 1, 2015
@Sjors Sjors deleted the void-0-csp-fix branch February 1, 2016 10:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants