From a91dc8a798ed57ca1c63a3e51b483de68d484df9 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 24 Dec 2016 19:59:09 +0100 Subject: [PATCH] BUG-2080: Fix for an exception when a filename on the clipboard doesn't have an extension. [skip ci] --- GreenshotPlugin/Core/ClipboardHelper.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/GreenshotPlugin/Core/ClipboardHelper.cs b/GreenshotPlugin/Core/ClipboardHelper.cs index 6e9162f19..a2462708d 100644 --- a/GreenshotPlugin/Core/ClipboardHelper.cs +++ b/GreenshotPlugin/Core/ClipboardHelper.cs @@ -811,19 +811,14 @@ EndSelection:<<<<<<<4 /// public static IEnumerable GetImageFilenames(IDataObject dataObject) { string[] dropFileNames = (string[]) dataObject.GetData(DataFormats.FileDrop); - if (dropFileNames != null && dropFileNames.Length > 0) { - foreach (string filename in dropFileNames) { - if (string.IsNullOrEmpty(filename)) - { - continue; - } - string ext = Path.GetExtension(filename).ToLower().Substring(1); - if (ImageHelper.StreamConverters.ContainsKey(ext)) - { - yield return filename; - } - } + if (dropFileNames != null && dropFileNames.Length > 0) + { + return dropFileNames.Where(filename => !string.IsNullOrEmpty(filename)) + .Where(Path.HasExtension) + .Select(filename => Path.GetExtension(filename).ToLowerInvariant()) + .Where(ext => ImageHelper.StreamConverters.Keys.Contains(ext)); } + return Enumerable.Empty(); } ///