Metadata can now only be string or null.
Fixes #1653
protected function buildFormData(array $link, bool $isNew, Request $request): array
{
- $link['tags'] = strlen($link['tags']) > 0
+ $link['tags'] = $link['tags'] !== null && strlen($link['tags']) > 0
? $link['tags'] . $this->container->conf->get('general.tags_separator', ' ')
: $link['tags']
;
$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);
}
}
$remoteCharset = 'utf-8';
$expectedResult = [
- 'title' => $remoteTitle,
+ 'title' => trim($remoteTitle),
'description' => $remoteDesc,
'tags' => $remoteTags,
];