From ecb615ecf10b4e21e04586a44edaf040a4333580 Mon Sep 17 00:00:00 2001 From: Tomlacko <72975448+Tomlacko@users.noreply.github.com> Date: Fri, 18 Feb 2022 04:58:47 +0100 Subject: [PATCH] Fix for extremely long file extensions (#812) --- DiscordChatExporter.Core/Exporting/MediaDownloader.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DiscordChatExporter.Core/Exporting/MediaDownloader.cs b/DiscordChatExporter.Core/Exporting/MediaDownloader.cs index 4765de5..946e227 100644 --- a/DiscordChatExporter.Core/Exporting/MediaDownloader.cs +++ b/DiscordChatExporter.Core/Exporting/MediaDownloader.cs @@ -103,7 +103,15 @@ internal partial class MediaDownloader // Otherwise, use the original file name but inject the hash in the middle var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); var fileExtension = Path.GetExtension(fileName); + + // Probably not a file extension, just a dot in a long file name + // https://github.com/Tyrrrz/DiscordChatExporter/issues/708 + if (fileExtension.Length > 41) + { + fileNameWithoutExtension = fileName; + fileExtension = ""; + } return PathEx.EscapeFileName(fileNameWithoutExtension.Truncate(42) + '-' + urlHash + fileExtension); } -} \ No newline at end of file +}