]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/http/MetadataRetriever.php
Fix: synchronous metadata retrieval is failing in strict mode
[github/shaarli/Shaarli.git] / application / http / MetadataRetriever.php
index 2ca982e21172236fb7aaaf957f0db8c255725b32..cfc72583e713a192f08199554388990d0d508f8b 100644 (file)
@@ -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.
@@ -46,12 +45,14 @@ class MetadataRetriever
             $url,
             $this->conf->get('general.download_timeout', 30),
             $this->conf->get('general.download_max_size', 4194304),
+            $this->httpAccess->getCurlHeaderCallback($charset),
             $this->httpAccess->getCurlDownloadCallback(
                 $charset,
                 $title,
                 $description,
                 $tags,
-                $retrieveDescription
+                $this->conf->get('general.retrieve_description'),
+                $this->conf->get('general.tags_separator', ' ')
             )
         );
 
@@ -59,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);
     }
 }