From 6a3a78d023aa320138bb88505b58347db268264a Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 16 Dec 2020 14:04:32 +0100 Subject: Fix: synchronous metadata retrieval is failing in strict mode Metadata can now only be string or null. Fixes #1653 --- application/http/MetadataRetriever.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'application/http') diff --git a/application/http/MetadataRetriever.php b/application/http/MetadataRetriever.php index 2e1401ec..cfc72583 100644 --- a/application/http/MetadataRetriever.php +++ b/application/http/MetadataRetriever.php @@ -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); } } -- cgit v1.2.3