X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2Fhttp%2FMetadataRetriever.php;h=cfc72583e713a192f08199554388990d0d508f8b;hb=6a3a78d023aa320138bb88505b58347db268264a;hp=ba9bd40ce283d4b789f194d13ac7e02883361c6f;hpb=dff039092d180fffa89e7d88f7a4b7bc24dfc80f;p=github%2Fshaarli%2FShaarli.git diff --git a/application/http/MetadataRetriever.php b/application/http/MetadataRetriever.php index ba9bd40c..cfc72583 100644 --- a/application/http/MetadataRetriever.php +++ b/application/http/MetadataRetriever.php @@ -38,7 +38,6 @@ class MetadataRetriever $title = null; $description = null; $tags = null; - $retrieveDescription = $this->conf->get('general.retrieve_description'); // Short timeout to keep the application responsive // The callback will fill $charset and $title with data from the downloaded page. @@ -52,7 +51,8 @@ class MetadataRetriever $title, $description, $tags, - $retrieveDescription + $this->conf->get('general.retrieve_description'), + $this->conf->get('general.tags_separator', ' ') ) ); @@ -60,10 +60,15 @@ class MetadataRetriever $title = mb_convert_encoding($title, 'utf-8', $charset); } - return [ + return array_map([$this, 'cleanMetadata'], [ 'title' => $title, 'description' => $description, 'tags' => $tags, - ]; + ]); + } + + protected function cleanMetadata($data): ?string + { + return !is_string($data) || empty(trim($data)) ? null : trim($data); } }