Просмотр исходного кода

SimplePie: Fix int types for enclosures (#8702)

channels, duration were wrongly parsed as string instead of int.

```
PHP Fatal error:  Uncaught TypeError: SimplePie\Enclosure::__construct():
Argument #12 ($duration) must be of type ?int, string given in simplepie/src/Enclosure.php:199
```

And add tests (there were none for those attributes)

fix https://github.com/FreshRSS/FreshRSS/issues/8701

Upstream PR:
* https://github.com/simplepie/simplepie/pull/975
* https://github.com/FreshRSS/simplepie/pull/74
Alexandre Alapetite 1 месяц назад
Родитель
Сommit
3d4dca5f5b
2 измененных файлов с 5 добавлено и 5 удалено
  1. 1 1
      lib/composer.json
  2. 4 4
      lib/simplepie/simplepie/src/Item.php

+ 1 - 1
lib/composer.json

@@ -14,7 +14,7 @@
 		"marienfressinaud/lib_opml": "0.5.1",
 		"marienfressinaud/lib_opml": "0.5.1",
 		"phpgt/cssxpath": "v1.5.0",
 		"phpgt/cssxpath": "v1.5.0",
 		"phpmailer/phpmailer": "7.0.2",
 		"phpmailer/phpmailer": "7.0.2",
-		"simplepie/simplepie": "dev-freshrss#731f1a60b8d011238bb5a2cb3b7cdea619e02b94"
+		"simplepie/simplepie": "dev-freshrss#33e4bcf5685192b0fa4c9819f0813b47c3d22424"
 	},
 	},
 	"config": {
 	"config": {
 		"sort-packages": true,
 		"sort-packages": true,

+ 4 - 4
lib/simplepie/simplepie/src/Item.php

@@ -1458,10 +1458,10 @@ class Item implements RegistryAware
                                 $bitrate = $this->sanitize($content['attribs']['']['bitrate'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
                                 $bitrate = $this->sanitize($content['attribs']['']['bitrate'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
                             }
                             }
                             if (isset($content['attribs']['']['channels'])) {
                             if (isset($content['attribs']['']['channels'])) {
-                                $channels = $this->sanitize($content['attribs']['']['channels'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
+                                $channels = (int) $this->sanitize($content['attribs']['']['channels'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
                             }
                             }
                             if (isset($content['attribs']['']['duration'])) {
                             if (isset($content['attribs']['']['duration'])) {
-                                $duration = $this->sanitize($content['attribs']['']['duration'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
+                                $duration = (int) $this->sanitize($content['attribs']['']['duration'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
                             } else {
                             } else {
                                 $duration = $duration_parent;
                                 $duration = $duration_parent;
                             }
                             }
@@ -1915,10 +1915,10 @@ class Item implements RegistryAware
                             $bitrate = $this->sanitize($content['attribs']['']['bitrate'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
                             $bitrate = $this->sanitize($content['attribs']['']['bitrate'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
                         }
                         }
                         if (isset($content['attribs']['']['channels'])) {
                         if (isset($content['attribs']['']['channels'])) {
-                            $channels = $this->sanitize($content['attribs']['']['channels'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
+                            $channels = (int) $this->sanitize($content['attribs']['']['channels'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
                         }
                         }
                         if (isset($content['attribs']['']['duration'])) {
                         if (isset($content['attribs']['']['duration'])) {
-                            $duration = $this->sanitize($content['attribs']['']['duration'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
+                            $duration = (int) $this->sanitize($content['attribs']['']['duration'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
                         } else {
                         } else {
                             $duration = $duration_parent;
                             $duration = $duration_parent;
                         }
                         }