Browse Source

Bump SimplePie (#8445)

https://github.com/simplepie/simplepie/pull/957
Alexandre Alapetite 2 months ago
parent
commit
ff7ce7b21d

+ 1 - 1
lib/composer.json

@@ -14,7 +14,7 @@
 		"marienfressinaud/lib_opml": "0.5.1",
 		"phpgt/cssxpath": "v1.4.0",
 		"phpmailer/phpmailer": "7.0.1",
-		"simplepie/simplepie": "dev-freshrss#ecc7ef140142d0fc224128efb10b48322b5f707c"
+		"simplepie/simplepie": "dev-freshrss#dbcf155c82a17872f0bf8562723cc809842064ee"
 	},
 	"config": {
 		"sort-packages": true,

+ 4 - 0
lib/simplepie/simplepie/.editorconfig

@@ -19,6 +19,10 @@ indent_style = space
 max_line_length = off
 trim_trailing_whitespace = false
 
+[*.neon]
+indent_size = 4
+indent_style = space
+
 [*.php]
 indent_size = 4
 indent_style = space

+ 1 - 0
lib/simplepie/simplepie/.gitignore

@@ -7,3 +7,4 @@ phpstan.neon
 phpunit.xml
 .php-cs-fixer.cache
 .phpunit.cache/
+.phpunit.result.cache

+ 1 - 0
lib/simplepie/simplepie/phpstan.dist.neon

@@ -5,6 +5,7 @@ parameters:
         - library/
         - src/
         - tests/
+        - utils/
 
     ignoreErrors:
         # Ignore that only one const exists atm

+ 3 - 2
lib/simplepie/simplepie/src/File.php

@@ -126,9 +126,10 @@ class File implements Response
                 } else {
                     curl_setopt($fp, CURLOPT_ENCODING, '');
                 }
+                /** @var non-empty-string $url */
                 curl_setopt($fp, CURLOPT_URL, $url);
-                curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
-                curl_setopt($fp, CURLOPT_FAILONERROR, 1);
+                curl_setopt($fp, CURLOPT_RETURNTRANSFER, true);
+                curl_setopt($fp, CURLOPT_FAILONERROR, true);
                 curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
                 curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
                 // curl_setopt($fp, CURLOPT_REFERER, \SimplePie\Misc::url_remove_credentials($url)); // FreshRSS removed

+ 2 - 2
lib/simplepie/simplepie/src/HTTP/Parser.php

@@ -243,7 +243,7 @@ class Parser
             $headers[$name][] = $value;
         } else {
             // For PHPStan: should be enforced by template parameter but PHPStan is not smart enough.
-            /** @var array<string, string>) */
+            /** @var array<string,string> */
             $headers = &$this->headers;
             $headers[$name] .= ', ' . $value;
         }
@@ -258,7 +258,7 @@ class Parser
             $headers[$name] = [$value];
         } else {
             // For PHPStan: should be enforced by template parameter but PHPStan is not smart enough.
-            /** @var array<string, string>) */
+            /** @var array<string,string> */
             $headers = &$this->headers;
             $headers[$name] = $value;
         }

+ 0 - 1
lib/simplepie/simplepie/src/Registry.php

@@ -125,7 +125,6 @@ class Registry
             return false;
         }
 
-        /** @var string */
         $base_class = $this->default[$type];
 
         if (!is_subclass_of($class, $base_class)) {

+ 6 - 0
lib/simplepie/simplepie/src/Sanitize.php

@@ -759,6 +759,9 @@ class Sanitize implements RegistryAware
 
         if ($this->encode_instead_of_strip) {
             foreach ($elements as $element) {
+                if (!($element instanceof \DOMNode)) {
+                    continue;
+                }
                 $fragment = $document->createDocumentFragment();
 
                 // For elements which aren't script or style, include the tag itself
@@ -815,6 +818,9 @@ class Sanitize implements RegistryAware
             return;
         } else {
             foreach ($elements as $element) {
+                if (!($element instanceof \DOMNode)) {
+                    continue;
+                }
                 $fragment = $document->createDocumentFragment();
                 $number = $element->childNodes->length;
                 for ($i = $number; $i > 0; $i--) {

+ 4 - 3
lib/simplepie/simplepie/src/SimplePie.php

@@ -1849,7 +1849,8 @@ class SimplePie
                 $single_success = $this->multifeed_objects[$i]->init();
                 $success |= $single_success;
                 if (!$single_success) {
-                    $this->error[$i] = $this->multifeed_objects[$i]->error();
+                    $error = $this->multifeed_objects[$i]->error() ?? '';
+                    $this->error[$i] = is_string($error) ? $error : implode('; ', $error);
                 }
                 $i++;
             }
@@ -1954,7 +1955,7 @@ class SimplePie
                     // Cache the file if caching is enabled
                     $this->data['cache_expiration_time'] = \SimplePie\HTTP\Utils::negociate_cache_expiration_time($this->data['headers'] ?? [], $this->cache_duration, $this->cache_duration_min, $this->cache_duration_max);
 
-                    if ($cache && !$cache->set_data($this->get_cache_filename($this->feed_url), $this->data, $this->cache_duration)) {
+                    if ($cache instanceof DataCache && !$cache->set_data($this->get_cache_filename($this->feed_url), $this->data, $this->cache_duration)) {
                         trigger_error("$this->cache_location is not writable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
                     }
                     return true;
@@ -3066,7 +3067,7 @@ class SimplePie
             }
             // https://datatracker.ietf.org/doc/html/rfc8288
             if (is_string($link_headers) &&
-                preg_match_all('/<(?P<uri>[^>]+)>\s*;\s*rel\s*=\s*(?P<quote>"?)' . preg_quote($rel) . '(?P=quote)\s*(?=,|$)/i', $link_headers, $matches)) {
+                preg_match_all('/<(?P<uri>[^>]+)>\s*;\s*rel\s*=\s*(?P<quote>"?)' . preg_quote($rel, '/') . '(?P=quote)\s*(?=,|$)/i', $link_headers, $matches)) {
                 return $matches['uri'];
             }
         }