PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | _inc/lib/class-jetpack-podcast-feed-locator.php +25 -8 12.9.5 → 16.3-beta View file →
@@ -1,24 +1,31 @@
1 1 <?php
2 2 /**
3 - * Extension of the SimplePie_Locator class, to detect podcast feeds
3 + * Extension of the SimplePie\Locator class, to detect podcast feeds
4 4 *
5 5 * @package automattic/jetpack
6 6 */
7 7
8 +if ( ! defined( 'ABSPATH' ) ) {
9 + exit( 0 );
10 +}
11 +
8 12 /**
9 13 * Class Jetpack_Podcast_Feed_Locator
10 14 */
11 -class Jetpack_Podcast_Feed_Locator extends SimplePie_Locator {
15 +class Jetpack_Podcast_Feed_Locator extends SimplePie\Locator {
16 +
12 17 /**
13 18 * Overrides the locator is_feed function to check for
14 19 * appropriate podcast elements.
15 20 *
16 - * @param SimplePie_File $file The file being checked.
17 - * @param boolean $check_html Adds text/html to the mimetypes checked.
21 + * @param SimplePie\HTTP\Response $file The file being checked.
22 + * @param boolean $check_html Adds text/html to the mimetypes checked.
18 23 */
19 24 public function is_feed( $file, $check_html = false ) {
20 - return parent::is_feed( $file, $check_html ) && $this->is_podcast_feed( $file );
25 + return parent::is_feed( $file, $check_html ) &&
26 + $file instanceof SimplePie\File &&
27 + $this->is_podcast_feed( $file );
21 28 }
22 29
23 30 /**
24 31 * Checks the contents of the file for elements that make
@@ -23,9 +30,9 @@
23 30 /**
24 31 * Checks the contents of the file for elements that make
25 32 * it a podcast feed.
26 33 *
27 - * @param SimplePie_File $file The file being checked.
34 + * @param SimplePie\File $file The file being checked.
28 35 */
29 36 private function is_podcast_feed( $file ) {
30 37 // If we can't read the DOM assume it's a podcast feed, we'll work
31 38 // it out later.
@@ -32,9 +39,15 @@
32 39 if ( ! class_exists( 'DOMDocument' ) ) {
33 40 return true;
34 41 }
35 42
36 - $feed_dom = $this->safely_load_xml( $file->body );
43 + // @todo Drop is_callable check once WordPress.com Simple gets the SimplePie update that came with WordPress 6.9.
44 + if ( is_callable( array( $file, 'get_body_content' ) ) ) {
45 + $feed_dom = $this->safely_load_xml( $file->get_body_content() );
46 + } else {
47 + // @phan-suppress-next-line PhanDeprecatedProperty -- For compatibility only.
48 + $feed_dom = $this->safely_load_xml( (string) $file->body );
49 + }
37 50
38 51 // Do this as either/or but prioritise the itunes namespace. It's pretty likely
39 52 // that it's a podcast feed we've found if that namespace is present.
40 53 return $feed_dom && $this->has_itunes_ns( $feed_dom ) && $this->has_audio_enclosures( $feed_dom );
@@ -43,11 +56,15 @@
43 56 /**
44 57 * Safely loads an XML file
45 58 *
46 59 * @param string $xml A string of XML to load.
47 - * @return DOMDocument|false A restulting DOM document or `false` if there is an error.
60 + * @return DOMDocument|false A resulting DOM document or `false` if there is an error.
48 61 */
49 62 private function safely_load_xml( $xml ) {
63 + if ( empty( $xml ) ) {
64 + return false;
65 + }
66 +
50 67 $disable_entity_loader = PHP_VERSION_ID < 80000;
51 68
52 69 if ( $disable_entity_loader ) {
53 70 // This function has been deprecated in PHP 8.0 because in libxml 2.9.0, external entity loading