Skip to content

Commit 28c8f21

Browse files
authored
Podcast feed: Prevent fatals when passing invalid arg to XML parser (#45498)
1 parent a1019a1 commit 28c8f21

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

projects/plugins/jetpack/_inc/lib/class-jetpack-podcast-feed-locator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private function is_podcast_feed( $file ) {
3737
return true;
3838
}
3939

40-
$feed_dom = $this->safely_load_xml( $file->body );
40+
$feed_dom = $this->safely_load_xml( (string) $file->body );
4141

4242
// Do this as either/or but prioritise the itunes namespace. It's pretty likely
4343
// that it's a podcast feed we've found if that namespace is present.
@@ -48,9 +48,13 @@ private function is_podcast_feed( $file ) {
4848
* Safely loads an XML file
4949
*
5050
* @param string $xml A string of XML to load.
51-
* @return DOMDocument|false A restulting DOM document or `false` if there is an error.
51+
* @return DOMDocument|false A resulting DOM document or `false` if there is an error.
5252
*/
5353
private function safely_load_xml( $xml ) {
54+
if ( empty( $xml ) ) {
55+
return false;
56+
}
57+
5458
$disable_entity_loader = PHP_VERSION_ID < 80000;
5559

5660
if ( $disable_entity_loader ) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: other
3+
4+
Podcast feed: Prevent fatals when content is empty.

0 commit comments

Comments
 (0)