Repository navigation
Widgets: Prevent an infinite loop in wp_widget_rss_process(). - #15892
rejaulalomkhan wants to merge 1 commit into
Conversation
The loop that trims a feed's channel link never ends when the link does not contain `http`, such as an FTP link or a channel without a link. Add the guard the other RSS widget loops already use, and cast the permalink to a string since it can be null. Fixes #62341.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
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. |
Trac ticket: Core-62341
Description
wp_widget_rss_process()removes characters from the start of a feed's channel link until the link starts withhttp. If the link has nohttpin it, the string becomes empty and thewhileloop never ends, so the request runs until PHP's execution time limit.On the ticket, abcd95 couldn't reproduce this because
esc_url()addshttp://to a link with no scheme. It doesn't do that for other cases:<link>ftp://example.com/</link>, stays as it is and reaches the loop.<link>element makesget_permalink()returnnull, which becomes an empty string. On PHP 8.1 and later,strip_tags()also raises a deprecation notice for thenull.This adds the
! empty( $link )guard that the matching loops inwp_widget_rss_output()andWP_Widget_RSS::widget()already have, and casts the permalink to a string. The function now returns an emptylinkfor these feeds.Not changed here:
WP_Widget_RSS::widget()also passesget_permalink()tostrip_tags()without a cast, so it can raise the same deprecation notice.Testing Instructions
FTP URLdata set never finishes, so use a timeout there, for exampletimeout 30 vendor/bin/phpunit --filter 'test_wp_widget_rss_process_channel_link@FTP URL'. Theno link elementdata set errors on thestrip_tags()deprecation.Results on PHP 8.3:
widgets508 tests and 2019 assertions,feed134 and 510, multisitewidgets508 and 2019, all passing.widgetsalso passes with--order-by=reverse. PHPCS is clean on both files, and PHPStan reports no errors onwidgets.php.Trac ticket: https://core.trac.wordpress.org/ticket/62341
This Pull Request is for code review only. Please keep all other discussion to the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: reproducing the bug, drafting the fix and test, running the checks listed above, and drafting this description. I reviewed every line and take responsibility for the change.