-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add sourceURL comments for directly constructed inline scripts in wp-includes #9955
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
Add sourceURL comments for directly constructed inline scripts in wp-includes #9955
Conversation
| } | ||
| dropdown.onchange = onCatChange; | ||
| })(); | ||
| //# sourceURL=<?php echo __FUNCTION__; ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this change will need to be done upstream in Gutenberg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sirreal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's pass all of these through rawurlencode() rather than any string replacement or otherwise relying on the strings to be safe.
That's how it's implemented in script loader:
| echo sprintf( "\n//# sourceURL=%s\n", rawurlencode( 'js-inline-concat-' . $concat ) ); |
The spec says this:
And rawurlencode() is just the thing:
Encodes the given string according to » RFC 3986.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
sirreal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested several but not all of these cases. I have reviewed all the changes and they appear correct.
It's a very nice improvement when errors or logs come from these scripts 👍
|
Have you or are you planning to create a PR for the case that comes from Gutenberg? |
@sirreal Thanks for the reminder: WordPress/gutenberg#72118 |
…lly constructed in `wp-includes`. This applies to tags constructed without `wp_get_inline_script_tag()`/`wp_print_inline_script_tag()`. Developed in #9955. Props westonruter, jonsurrell. See #63887. git-svn-id: https://develop.svn.wordpress.org/trunk@60909 602fd350-edb4-49c9-b593-d223f7449a82
…lly constructed in `wp-includes`. This applies to tags constructed without `wp_get_inline_script_tag()`/`wp_print_inline_script_tag()`. Developed in WordPress/wordpress-develop#9955. Props westonruter, jonsurrell. See #63887. Built from https://develop.svn.wordpress.org/trunk@60909 git-svn-id: http://core.svn.wordpress.org/trunk@60245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…lly constructed in `wp-includes`. This applies to tags constructed without `wp_get_inline_script_tag()`/`wp_print_inline_script_tag()`. Developed in WordPress/wordpress-develop#9955. Props westonruter, jonsurrell. See #63887. Built from https://develop.svn.wordpress.org/trunk@60909 git-svn-id: https://core.svn.wordpress.org/trunk@60245 1a063a9b-81f0-0310-95a4-ce76da25c4cd

I realized in https://github.com/WordPress/wordpress-develop/pull/9531/files#r2361414013 that that the emoji loader script wasn't geting the
sourceURLcomment. I then realized that there were more than a dozen other such instances of scripts constructed viawp_get_inline_script_tag()andwp_print_inline_script_tag()inwp-includeswhich lacked these comments.Note that there are quite a few scripts constructed in
wp-adminwhich are not yet usingwp_get_inline_script_tag()andwp_print_inline_script_tag(). See Core-59446.There are also instances of inline scripts being printed in themes which this PR does not address. I've suggested that these be handled as part of Core-63806.
Trac ticket: https://core.trac.wordpress.org/ticket/63887
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.