From: joshuaruesweg Date: Wed, 10 Mar 2021 14:28:39 +0000 (+0100) Subject: Trim title, description and imageUrl X-Git-Tag: 5.4.0_Alpha_1~146^2~12 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ac7b4144595c627af9bf92ce131714e8a0dec057;p=GitHub%2FWoltLab%2FWCF.git Trim title, description and imageUrl --- diff --git a/wcfsetup/install/files/lib/system/background/job/UnfurlUrlBackgroundJob.class.php b/wcfsetup/install/files/lib/system/background/job/UnfurlUrlBackgroundJob.class.php index 1ac75edb85..7102a9e7d4 100644 --- a/wcfsetup/install/files/lib/system/background/job/UnfurlUrlBackgroundJob.class.php +++ b/wcfsetup/install/files/lib/system/background/job/UnfurlUrlBackgroundJob.class.php @@ -75,19 +75,23 @@ final class UnfurlUrlBackgroundJob extends AbstractBackgroundJob return; } - $title = StringUtil::truncate($unfurlResponse->getTitle(), 255); + $title = StringUtil::truncate(StringUtil::trim($unfurlResponse->getTitle()), 255); $description = ""; if ($unfurlResponse->getDescription()) { - $description = StringUtil::truncate($unfurlResponse->getDescription(), 160); + $description = StringUtil::truncate(StringUtil::trim($unfurlResponse->getDescription()), 160); } $imageData = []; $imageID = null; - if ($unfurlResponse->getImageUrl() && Url::is($unfurlResponse->getImageUrl())) { - $imageID = self::getImageIdByUrl($unfurlResponse->getImageUrl()); + if ($unfurlResponse->getImageUrl()) { + $imageUrl = StringUtil::trim($unfurlResponse->getImageUrl()); - if ($imageID === null) { - $imageData = $this->getImageData($unfurlResponse); + if (Url::is($imageUrl)) { + $imageID = self::getImageIdByUrl($unfurlResponse->getImageUrl()); + + if ($imageID === null) { + $imageData = $this->getImageData($unfurlResponse); + } } } @@ -122,7 +126,7 @@ final class UnfurlUrlBackgroundJob extends AbstractBackgroundJob if ($imageData !== false) { if ($this->validateImage($imageData)) { - $imageSaveData['imageUrl'] = $unfurlResponse->getImageUrl(); + $imageSaveData['imageUrl'] = StringUtil::trim($unfurlResponse->getImageUrl()); $imageSaveData['width'] = $imageData[0]; $imageSaveData['height'] = $imageData[1]; if (!(MODULE_IMAGE_PROXY || IMAGE_ALLOW_EXTERNAL_SOURCE)) {