diff options
| author | 2021-03-23 10:54:14 +0100 | |
|---|---|---|
| committer | 2021-03-23 10:54:14 +0100 | |
| commit | 0ff6ba45429e7b089ca3c0459e0216a77a53898b (patch) | |
| tree | e0c332d1d5906a1e2252ed20c4395d545155f9f2 /lib | |
| parent | dd80445d69781b44020e32236ba5024d2e0dc3e1 (diff) | |
SimplePie fix PHP8 uncatched error (#3547)
#fix https://github.com/FreshRSS/FreshRSS/pull/3546
When `loadHTML()` is given a null or empty string.
```
PHP Fatal error: Uncaught ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty in /var/www/freshrss/lib/SimplePie/SimplePie/Locator.php:83
```
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/SimplePie/SimplePie/Locator.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/SimplePie/SimplePie/Locator.php b/lib/SimplePie/SimplePie/Locator.php index a207df6fe..ebc7ec9c1 100644 --- a/lib/SimplePie/SimplePie/Locator.php +++ b/lib/SimplePie/SimplePie/Locator.php @@ -75,12 +75,19 @@ class SimplePie_Locator $this->force_fsockopen = $force_fsockopen; $this->curl_options = $curl_options; - if (class_exists('DOMDocument')) + if (class_exists('DOMDocument') && $this->file->body != '') { $this->dom = new DOMDocument(); set_error_handler(array('SimplePie_Misc', 'silence_errors')); - $this->dom->loadHTML($this->file->body); + try + { + $this->dom->loadHTML($this->file->body); + } + catch (Throwable $ex) + { + $this->dom = null; + } restore_error_handler(); } else |
