Skip to content

Conversation

@westonruter
Copy link
Member

@westonruter westonruter commented Sep 19, 2025

I realized in https://github.com/WordPress/wordpress-develop/pull/9531/files#r2361414013 that that the emoji loader script wasn't geting the sourceURL comment. I then realized that there were more than a dozen other such instances of scripts constructed via wp_get_inline_script_tag() and wp_print_inline_script_tag() in wp-includes which lacked these comments.

Note that there are quite a few scripts constructed in wp-admin which are not yet using wp_get_inline_script_tag() and wp_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.

}
dropdown.onchange = onCatChange;
})();
//# sourceURL=<?php echo __FUNCTION__; ?>
Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

@westonruter westonruter requested a review from sirreal September 19, 2025 00:58
Copy link
Member

@sirreal sirreal left a 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:

Note: is a URL as defined in RFC3986; in particular, characters outside the set permitted to appear in URIs must be percent-encoded.

And rawurlencode() is just the thing:

Encodes the given string according to » RFC 3986.

@westonruter
Copy link
Member Author

Note how the function now shows up in the coverage report:

image

@github-actions
Copy link

github-actions bot commented Oct 4, 2025

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@westonruter westonruter marked this pull request as ready for review October 4, 2025 04:49
@westonruter westonruter requested a review from sirreal October 4, 2025 04:49
@github-actions
Copy link

github-actions bot commented Oct 4, 2025

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props westonruter, jonsurrell.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@sirreal sirreal left a 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 👍

@sirreal
Copy link
Member

sirreal commented Oct 6, 2025

Have you or are you planning to create a PR for the case that comes from Gutenberg?

@westonruter
Copy link
Member Author

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

pento pushed a commit that referenced this pull request Oct 7, 2025
…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
@westonruter
Copy link
Member Author

Committed in r60909 (8c2ec29)

@westonruter westonruter closed this Oct 7, 2025
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Oct 7, 2025
…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
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Oct 7, 2025
…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
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.

2 participants