Refactor <script> tag to be generated by wp_get_script_tag and related functions.#498
Open
enricocarraro wants to merge 56 commits intoWordPress:masterfrom
Open
Conversation
cda5081 to
cd28054
Compare
felixarntz
reviewed
Aug 27, 2020
Member
felixarntz
left a comment
There was a problem hiding this comment.
It looks like there are some WordPress coding standards violations in here: https://travis-ci.com/github/WordPress/wordpress-develop/jobs/378458383 Have you set up your local environment to lint for these?
felixarntz
reviewed
Sep 4, 2020
swissspidy
reviewed
Oct 2, 2020
swissspidy
reviewed
Oct 2, 2020
swissspidy
reviewed
Oct 2, 2020
swissspidy
reviewed
Oct 2, 2020
swissspidy
reviewed
Oct 2, 2020
enricocarraro
commented
Oct 2, 2020
src/wp-includes/functions.php
Outdated
| * @param string $javascript Inline JavaScript code. | ||
| * @param array $attributes Key-value pairs representing `<script>` tag attributes. | ||
| */ | ||
| do_action( 'wp_get_inline_script_tag', $javascript, $attributes ); |
Author
There was a problem hiding this comment.
@Ayesh I added the change you suggested. Would you mind giving me your opinion on this?
It can be used in the following way:
add_action(
'wp_get_inline_script_tag',
function ( $js ) {
$hash = sha256( $js );
header( "Content-Security-Policy: script-src 'sha256-$hash'" );
}
);Edit: the change was reverted; relevant discussion here.
<script> tag to be generated by wp_get_script_tag and related functions.
1c12606 to
609bdbe
Compare
8defd6c to
24c26b9
Compare
…s/script-loader.php`.
…s/widgets/class-wp-widget-categories.php`.
…ncludes/misc.php`.
…ncludes/meta-boxes.php`.
…ncludes/media.php`.
…ncludes/deprecated.php`.
…ncludes/class-wp-upgrader-skin.php`.
…ncludes/class-wp-themes-list-table.php`.
…ncludes/class-wp-list-table.php`.
…ncludes/class-wp-internal-pointers.php`.
…ncludes/class-custom-image-header.php`.
…ncludes/class-bulk-upgrader-skin.php`.
…ncludes/ajax-actions.php`.
…dit-tag-form.php`.
…dit-form-comment.php`.
…dit-form-advanced.php`.
…dmin-header.php`.
…dmin-footer.php`.
…s/functions.php`.
24c26b9 to
2420dc1
Compare
3 tasks
Closed
Contributor
|
Closed with changeset https://core.trac.wordpress.org/changeset/50167 |
Member
|
@hellofromtonya Actually, no. That commit only resolved #498. |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR uses the newly introduced script tag formatting functions introduced in #591 to generate every script tag.
I followed this guide on adopting CSP, considering the
strict-dynamicoption enabled.I made a plugin prototype that enables Strict CSP to test these changes.
Trac ticket: https://core.trac.wordpress.org/ticket/39941
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.