X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FPageInfo.php;h=be8d055c96ef8b25fbed99b13635e295a3a9b932;hb=76c006d5603250b06db2c54ecdc9483af8d47b36;hp=21f32cd3c38dad350c1f6795595333c6195ec5dc;hpb=77e1ec6df2076183cf3643170a474278f368f968;p=friendica.git diff --git a/src/Content/PageInfo.php b/src/Content/PageInfo.php index 21f32cd3c3..be8d055c96 100644 --- a/src/Content/PageInfo.php +++ b/src/Content/PageInfo.php @@ -1,6 +1,6 @@ $body]); + Logger::debug('add_page_info_to_body: fetch page info for body', ['body' => $body]); $url = self::getRelevantUrlFromBody($body, $searchNakedUrls); if (!$url) { @@ -64,7 +64,7 @@ class PageInfo * @return string * @throws HTTPException\InternalServerErrorException */ - public static function appendDataToBody(string $body, array $data, bool $no_photos = false) + public static function appendDataToBody(string $body, array $data, bool $no_photos = false): string { // Only one [attachment] tag per body is allowed $existingAttachmentPos = strpos($body, '[attachment'); @@ -90,7 +90,7 @@ class PageInfo * @return string * @throws HTTPException\InternalServerErrorException */ - public static function getFooterFromUrl(string $url, bool $no_photos = false, string $photo = '', bool $keywords = false, string $keyword_denylist = '') + public static function getFooterFromUrl(string $url, bool $no_photos = false, string $photo = '', bool $keywords = false, string $keyword_denylist = ''): string { $data = self::queryUrl($url, $photo, $keywords, $keyword_denylist); @@ -103,7 +103,7 @@ class PageInfo * @return string * @throws HTTPException\InternalServerErrorException */ - public static function getFooterFromData(array $data, bool $no_photos = false) + public static function getFooterFromData(array $data, bool $no_photos = false): string { Hook::callAll('page_info_data', $data); @@ -141,7 +141,7 @@ class PageInfo $data['text'] = ''; } - // Only embedd a picture link when it seems to be a valid picture ("width" is set) + // Only embed a picture link when it seems to be a valid picture ("width" is set) if (!empty($data['images']) && !empty($data['images'][0]['width'])) { $preview = str_replace(['[', ']'], ['[', ']'], htmlentities($data['images'][0]['src'], ENT_QUOTES, 'UTF-8', false)); // if the preview picture is larger than 500 pixels then show it in a larger mode @@ -208,7 +208,7 @@ class PageInfo } } - Logger::info('fetch page info for URL', ['url' => $url, 'data' => $data]); + Logger::debug('fetch page info for URL', ['url' => $url, 'data' => $data]); return $data; } @@ -220,7 +220,7 @@ class PageInfo * @return array * @throws HTTPException\InternalServerErrorException */ - public static function getTagsFromUrl(string $url, string $photo = '', string $keyword_denylist = '') + public static function getTagsFromUrl(string $url, string $photo = '', string $keyword_denylist = ''): array { $data = self::queryUrl($url, $photo, true, $keyword_denylist); @@ -257,11 +257,11 @@ class PageInfo $body = preg_replace("/([#@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '', $body); // Search for pure links - preg_match("/\[url\](.*?)\[\/url\]/ism", $body, $matches); + preg_match("/\[url\](https?:.*?)\[\/url\]/ism", $body, $matches); if (!$matches) { // Search for links with descriptions - preg_match("/\[url\=(.*?)\].*?\[\/url\]/ism", $body, $matches); + preg_match("/\[url\=(https?:.*?)\].*?\[\/url\]/ism", $body, $matches); } if (!$matches && $searchNakedUrls) { @@ -282,7 +282,7 @@ class PageInfo * @param string $url * @return string */ - protected static function stripTrailingUrlFromBody(string $body, string $url) + protected static function stripTrailingUrlFromBody(string $body, string $url): string { $quotedUrl = preg_quote($url, '#'); $body = preg_replace_callback("#(?: