X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FParseUrl.php;h=24089b9cbd2a92bb33c22fe4e41ee3b501987cff;hb=3263f724c6d2139ebb71d0d6513f77fb157195e0;hp=40cb0b8fc099eaa42763fd4ddbd06ecd062d1185;hpb=99244d33f504349e4e11e5d3a6d0a3c505f12fee;p=friendica.git diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 40cb0b8fc0..24089b9cbd 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -135,23 +135,23 @@ class ParseUrl $siteinfo['url'] = $url; $siteinfo['type'] = 'link'; - $data = Network::curl($url); - if (!$data['success']) { + $curlResult = Network::curl($url); + if (!$curlResult->isSuccess()) { return $siteinfo; } // If the file is too large then exit - if ($data['info']['download_content_length'] > 1000000) { + if (defaults($curlResult->getInfo(), 'download_content_length', 0) > 1000000) { return $siteinfo; } // If it isn't a HTML file then exit - if (($data['info']['content_type'] != '') && !strstr(strtolower($data['info']['content_type']), 'html')) { + if (($curlResult->getContentType() != '') && !strstr(strtolower($curlResult->getContentType()), 'html')) { return $siteinfo; } - $header = $data['header']; - $body = $data['body']; + $header = $curlResult->getHeader(); + $body = $curlResult->getBody(); if ($do_oembed) { $oembed_data = OEmbed::fetchURL($url); @@ -161,7 +161,8 @@ class ParseUrl $siteinfo['type'] = $oembed_data->type; } - if (($oembed_data->type == 'link') && ($siteinfo['type'] != 'photo')) { + // See https://github.com/friendica/friendica/pull/5763#discussion_r217913178 + if ($siteinfo['type'] != 'photo') { if (isset($oembed_data->title)) { $siteinfo['title'] = trim($oembed_data->title); } @@ -337,7 +338,7 @@ class ParseUrl $siteinfo['type'] = 'link'; } - if ((@$siteinfo['image'] == '') && !$no_guessing) { + if (empty($siteinfo['image']) && !$no_guessing) { $list = $xpath->query('//img[@src]'); foreach ($list as $node) { $img_tag = []; @@ -486,21 +487,23 @@ class ParseUrl $complete = $schemearr["scheme"]."://".$schemearr["host"]; - if (@$schemearr["port"] != "") { + if (!empty($schemearr["port"])) { $complete .= ":".$schemearr["port"]; } - if (strpos($urlarr["path"], "/") !== 0) { - $complete .= "/"; - } + if (!empty($urlarr["path"])) { + if (strpos($urlarr["path"], "/") !== 0) { + $complete .= "/"; + } - $complete .= $urlarr["path"]; + $complete .= $urlarr["path"]; + } - if (@$urlarr["query"] != "") { + if (!empty($urlarr["query"])) { $complete .= "?".$urlarr["query"]; } - if (@$urlarr["fragment"] != "") { + if (!empty($urlarr["fragment"])) { $complete .= "#".$urlarr["fragment"]; }