X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FItem.php;h=b12624aa49a248e5b25a5d8981d17840e3c2cacb;hb=4b5c6994b26a8b6bcb3e92afb4a46a537b796aa7;hp=d148bf2738b4be60d0eec490e45cff1f7f5fffae;hpb=b402a760a8368de5cacfc4b9e1655d4eb173ffb4;p=friendica.git diff --git a/src/Model/Item.php b/src/Model/Item.php index d148bf2738..b12624aa49 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -220,10 +220,7 @@ class Item $content_fields['raw-body'] = Post\Media::insertFromBody($item['uri-id'], $content_fields['raw-body']); $content_fields['raw-body'] = self::setHashtags($content_fields['raw-body']); - if ($item['author-network'] != Protocol::DFRN) { - Post\Media::insertFromRelevantUrl($item['uri-id'], $content_fields['raw-body']); - } - + Post\Media::insertFromRelevantUrl($item['uri-id'], $content_fields['raw-body']); Post\Content::update($item['uri-id'], $content_fields); } @@ -1148,9 +1145,7 @@ class Item $item['raw-body'] = Post\Media::insertFromBody($item['uri-id'], $item['raw-body']); $item['raw-body'] = self::setHashtags($item['raw-body']); - if (!DBA::exists('contact', ['id' => $item['author-id'], 'network' => Protocol::DFRN])) { - Post\Media::insertFromRelevantUrl($item['uri-id'], $item['raw-body']); - } + Post\Media::insertFromRelevantUrl($item['uri-id'], $item['raw-body']); // Check for hashtags in the body and repair or add hashtag links $item['body'] = self::setHashtags($item['body']); @@ -3099,11 +3094,20 @@ class Item { // Make sure that for example site parameters aren't used when testing if the link is contained in the body $urlparts = parse_url($url); - if (!empty($urlparts)) { - unset($urlparts['query']); - unset($urlparts['fragment']); + if (empty($urlparts)) { + return false; + } + + unset($urlparts['query']); + unset($urlparts['fragment']); + + try { $url = (string)Uri::fromParts($urlparts); - } else { + } catch (\InvalidArgumentException $e) { + DI::logger()->notice('Invalid URL', ['$url' => $url, '$urlparts' => $urlparts]); + /* See https://github.com/friendica/friendica/issues/12113 + * Malformed URLs will result in a Fatal Error + */ return false; } @@ -3116,12 +3120,14 @@ class Item if (strpos($body, $url)) { return true; } + foreach ([0, 1, 2] as $size) { if (preg_match('#/photo/.*-' . $size . '\.#ism', $url) && strpos(preg_replace('#(/photo/.*)-[012]\.#ism', '$1-' . $size . '.', $body), $url)) { return true; } } + return false; } @@ -3418,7 +3424,7 @@ class Item $percent = $option['replies'] / $question['voters'] * 100; $options[$key]['vote'] = DI::l10n()->tt('%2$s (%3$d%%, %1$d vote)', '%2$s (%3$d%%, %1$d votes)', $option['replies'], $option['name'], round($percent, 1)); } else { - $options[$key]['vote'] = DI::l10n()->tt('%2$s (%1$d vote)', '%2$s (%1$d votes)', $option['replies'], $option['name'], ); + $options[$key]['vote'] = DI::l10n()->tt('%2$s (%1$d vote)', '%2$s (%1$d votes)', $option['replies'], $option['name']); } }