Avoid more local links and bad http requests
This commit is contained in:
parent
fc46778a00
commit
999cdc7db9
11 changed files with 62 additions and 81 deletions
|
@ -368,10 +368,13 @@ class APContact
|
|||
|
||||
// Unhandled from Kroeg
|
||||
// kroeg:blocks, updated
|
||||
if (!empty($apcontact['photo'])) {
|
||||
$apcontact['photo'] = trim($apcontact['photo']);
|
||||
}
|
||||
|
||||
if (!empty($apcontact['photo']) && !Network::isValidHttpUrl($apcontact['photo'])) {
|
||||
Logger::info('Invalid URL for photo', ['url' => $apcontact['url'], 'photo' => $apcontact['photo']]);
|
||||
$apcontact['photo'] = null;
|
||||
Logger::warning('Invalid URL for photo', ['url' => $apcontact['url'], 'photo' => $apcontact['photo']]);
|
||||
$apcontact['photo'] = '';
|
||||
}
|
||||
|
||||
// When the photo is too large, try to shorten it by removing parts
|
||||
|
|
|
@ -2204,13 +2204,18 @@ class Contact
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Network::isValidHttpUrl($avatar)) {
|
||||
Logger::warning('Invalid avatar', ['cid' => $cid, 'avatar' => $avatar]);
|
||||
$avatar = '';
|
||||
}
|
||||
|
||||
$uid = $contact['uid'];
|
||||
|
||||
// Only update the cached photo links of public contacts when they already are cached
|
||||
if (($uid == 0) && !$force && empty($contact['thumb']) && empty($contact['micro']) && !$create_cache) {
|
||||
if (($contact['avatar'] != $avatar) || empty($contact['blurhash'])) {
|
||||
$update_fields = ['avatar' => $avatar];
|
||||
if (!Network::isLocalLink($avatar) && Network::isValidHttpUrl($avatar)) {
|
||||
if (!Network::isLocalLink($avatar)) {
|
||||
$fetchResult = HTTPSignature::fetchRaw($avatar, 0, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]);
|
||||
|
||||
$img_str = $fetchResult->getBody();
|
||||
|
|
|
@ -3682,7 +3682,7 @@ class Item
|
|||
return is_numeric($hookData['item_id']) ? $hookData['item_id'] : 0;
|
||||
}
|
||||
|
||||
$fetched_uri = ActivityPub\Processor::fetchMissingActivity($uri);
|
||||
$fetched_uri = ActivityPub\Processor::fetchMissingActivity($uri, [], '', ActivityPub\Receiver::COMPLETION_MANUAL, $uid);
|
||||
|
||||
if ($fetched_uri) {
|
||||
$item_id = self::searchByLink($fetched_uri, $uid);
|
||||
|
|
|
@ -36,6 +36,7 @@ use Friendica\Object\Image;
|
|||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Images;
|
||||
use Friendica\Security\Security;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Proxy;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
|
@ -582,8 +583,13 @@ class Photo
|
|||
|
||||
$photo_failure = false;
|
||||
|
||||
if (!Network::isValidHttpUrl($image_url)) {
|
||||
Logger::warning('Invalid image url', ['image_url' => $image_url, 'uid' => $uid, 'cid' => $cid, 'callstack' => System::callstack(20)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$filename = basename($image_url);
|
||||
if (!empty($image_url) && @parse_url($image_url, PHP_URL_HOST)) {
|
||||
if (!empty($image_url)) {
|
||||
$ret = DI::httpClient()->get($image_url, HttpClientAccept::IMAGE);
|
||||
Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
|
||||
$img_str = $ret->getBody();
|
||||
|
|
|
@ -194,7 +194,7 @@ class Tag
|
|||
} elseif (Contact::getIdForURL($url, 0, $fetch ? null : false)) {
|
||||
$target = self::ACCOUNT;
|
||||
Logger::debug('URL is an account', ['url' => $url]);
|
||||
} elseif ($fetch && ($target != self::GENERAL_COLLECTION) && Network::isValidHttpUrl($url)) {
|
||||
} elseif ($fetch && ($target != self::GENERAL_COLLECTION)) {
|
||||
$content = ActivityPub::fetchContent($url);
|
||||
if (!empty($content['type']) && ($content['type'] == 'OrderedCollection')) {
|
||||
$target = self::GENERAL_COLLECTION;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue