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

Move JavaScript form submission to script block #1620

Merged
merged 1 commit into from
Aug 20, 2019
Merged

Move JavaScript form submission to script block #1620

merged 1 commit into from
Aug 20, 2019

Conversation

jezen
Copy link
Member

@jezen jezen commented Aug 19, 2019

If someone wants their website to score a good grade on a security vulnerability scanner like Mozilla Observatory, they will need to enable the Content Security Policy header. When using CSP, it is possible to explicitly allow inline JavaScript in <script> tags by specifying the sha256 of the snippet. However the same is not true of any JavaScript included in a HTML attribute like onload.

This changes moves the JavaScript form submission out of the onload HTML attribute and into a <script> tag so the user can add the hash of this script to their explicitly-allowed script-src list, and they can avoid using undesirable CSP rules like unsafe-inline.

Without explicitly allowing this script when using CSP, the script would fail and the user would have to click the button to continue.

  • Bumped the version number
  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

If someone wants their website to score a good grade on a security
vulnerability scanner like Mozilla Observatory, they will need to enable
the Content Security Policy header. When using CSP, it is possible to
explicitly allow inline JavaScript in `<script>` tags by specifying the
sha256 of the snippet. However the same is _not_ true of any JavaScript
included in a HTML attribute like `onload`.

This changes moves the JavaScript form submission out of the `onload`
HTML attribute and into a `<script>` tag so the user can add the hash of
this script to their explicitly-allowed `script-src` list, and they can
avoid using undesirable CSP rules like `unsafe-inline`.

Without explicitly allowing this script when using CSP, the script would
fail and the user would have to click the button to continue.
@snoyberg snoyberg merged commit 56e8557 into yesodweb:master Aug 20, 2019
@snoyberg
Copy link
Member

Thanks!

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.

None yet

2 participants