]> git.mxchange.org Git - friendica.git/commitdiff
Exceptions and warnings fixed
authorMichael <heluecht@pirati.ca>
Thu, 29 Feb 2024 04:40:04 +0000 (04:40 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 29 Feb 2024 04:40:04 +0000 (04:40 +0000)
src/Protocol/Email.php
src/Util/ParseUrl.php

index 68d56da8bca78e7b71505d7bd3e2d8029a451bbd..836235105cae56194042903270457a112795849d 100644 (file)
@@ -259,7 +259,7 @@ class Email
 
                if ((isset($params['filename']) && $params['filename']) || (isset($params['name']) && $params['name'])) {
                        // filename may be given as 'Filename' or 'Name' or both
-                       $filename = ($params['filename'])? $params['filename'] : $params['name'];
+                       $filename = $params['filename'] ?? $params['name'];
                        // filename may be encoded, so see imap_mime_header_decode()
                        $attachments[$filename] = $data;  // this is a problem if two files have same name
                }
index 7c9a058b43223105be88ee43dd5bcf9d9282c0e8..d12d84278ba95e41753db9fa470496aeb6c563d5 100644 (file)
@@ -235,7 +235,12 @@ class ParseUrl
                        return $siteinfo;
                }
 
-               $curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::CONTENT_LENGTH => 1000000]);
+               try {
+                       $curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::CONTENT_LENGTH => 1000000]);
+               } catch (\Throwable $th) {
+                       Logger::info('Exception when fetching', ['url' => $url, 'code' => $th->getCode(), 'message' => $th->getMessage()]);
+                       return $siteinfo;
+               }
                if (!$curlResult->isSuccess() || empty($curlResult->getBodyString())) {
                        Logger::info('Empty body or error when fetching', ['url' => $url, 'success' => $curlResult->isSuccess(), 'code' => $curlResult->getReturnCode()]);
                        return $siteinfo;