-
Notifications
You must be signed in to change notification settings - Fork 835
Podcast feed: Prevent fatals when passing invalid arg to XML parser #45498
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
Podcast feed: Prevent fatals when passing invalid arg to XML parser #45498
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 1 file.
|
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.
Pull Request Overview
This PR prevents fatal errors in the podcast feed locator when handling invalid or empty XML content by adding proper validation and type casting.
Key Changes:
- Added early return when XML content is empty to prevent
DOMDocument::loadXML()
fatal error - Cast
$file->body
to string to ensure proper type handling
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
projects/plugins/jetpack/changelog/fix-jetpack-fatals_when_passing_invalid_arg_to_xml_parser | Added changelog entry documenting the fatal error prevention fix |
projects/plugins/jetpack/_inc/lib/class-jetpack-podcast-feed-locator.php | Added empty string validation and type casting to prevent XML parser fatals |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Makes sense to me
Closes MONOREP-148
This addresses the following fatal:
I made two changes:
Instead of usingOnly available in WP 6.9 (thanks, Phan). Cast$file->body
, let's use$file->get_body_content()
, which simply castsbody
to a string.$file->body
to string.$xml
is empty.Proposed changes:
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: