From c6f4f40bba03184f9655fe62ac8fd26833a910e1 Mon Sep 17 00:00:00 2001 From: Miguel Dantas Date: Thu, 12 Sep 2019 22:11:45 +0100 Subject: [PATCH] [Embed][CORE] Fixes 'Invalid Filename' on Embed. Regex didn't get updated --- lib/media/mediafile.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/media/mediafile.php b/lib/media/mediafile.php index 3fa94335bd..2eb77c08c6 100644 --- a/lib/media/mediafile.php +++ b/lib/media/mediafile.php @@ -272,14 +272,17 @@ class MediaFile */ public static function decodeFilename(string $encoded_filename) { - // The x is because it is using in thumbnails - $ret = preg_match('/^([^-x]+?)-[^-]+$/', $encoded_filename, $matches); + // Should match: + // hex-hash + // thumb-id-widthxheight-hex-hash + // And return the `hex` part + $ret = preg_match('/^(.*-)?([^-]+)-[^-]+$/', $encoded_filename, $matches); if ($ret === false) { return false; } elseif ($ret === 0) { return null; // No match } else { - $filename = hex2bin($matches[1]); + $filename = hex2bin($matches[2]); // Matches extension if (preg_match('/^(.+?)\.(.+)$/', $filename, $sub_matches) === 1) {