From ced610d94241a4a2b06f258ddc41848321688038 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Thu, 29 Apr 2021 12:53:42 +0000 Subject: [PATCH] [Embed] Use Formatting utilities rather than substr and such --- plugins/Embed/Embed.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/Embed/Embed.php b/plugins/Embed/Embed.php index 2112f331c7..9157b0f1f9 100644 --- a/plugins/Embed/Embed.php +++ b/plugins/Embed/Embed.php @@ -364,8 +364,8 @@ END, ['embed' => $embed, 'attributes' => $attributes]); $url = $attachment->getRemoteUrl(); - if (substr($url, 0, 7) == 'file://') { - $filename = substr($url, 7); + if (Formatting::startsWith($url, 'file://')) { + $filename = Formatting::removePrefix($url, 'file://'); $info = getimagesize($filename); $filename = basename($filename); $width = $info[0]; @@ -446,7 +446,7 @@ END, ['embed' => $embed, 'attributes' => $attributes]); $metadata['provider_url'] = $info->providerUrl; if (!is_null($info->image)) { - if (substr($info->image, 0, 4) === 'data') { + if (Formatting::startsWith($info->image, 'data')) { // Inline image $imgData = base64_decode(substr($info->image, stripos($info->image, 'base64,') + 7)); [$filepath, $width, $height, $original_name, $mimetype] = $this->validateAndWriteImage($imgData);