General: Fix wp_get_tooltip_helper() treating button markup as sprintf() format string. - #13201
Conversation
…f() format string. Fixes #65914
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @parthjogi-nyusoft. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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. |
Fixes #65914
wp_get_tooltip_helper() concatenated caller-supplied button markup directly
into a sprintf() format string. Any
%in that markup (e.g. a percent-encodedURL, or a meta box ID like
sale_100%_off) was parsed as a conversionspecification, causing either a fatal ValueError or silently corrupted output.
This patch passes the button markup to sprintf() as a plain argument instead
of concatenating it into the format string. The default core-generated
button's label/icon/popovertarget placeholders are now filled via
str_replace() on internal tokens before that point, so default-button
behavior is unchanged.
Added 5 tests to tests/phpunit/tests/general/wpGetTooltip.php covering the
exact repro cases from the ticket plus a regression check for the default
button. Full test file passes locally: 16 tests, 43 assertions.
Trac ticket: https://core.trac.wordpress.org/ticket/65914
Use of AI Tools
AI assistance: Yes
Tool(s): Claude (Anthropic)
Used for: Diagnosis of the root cause, implementation of the fix, and the
regression test suite. I reviewed the code, applied it in my local
wordpress-develop environment, and ran the full test suite
(16 tests, 43 assertions, all passing) before submitting.
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.