Skip to content

Commit ba57cf3

Browse files
committed
Added handling for empty extension parameters in ImageFormatManager.TryFindFormatByFileExtension
1 parent 82d3906 commit ba57cf3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ImageSharp/Formats/ImageFormatManager.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ public void AddImageFormat(IImageFormat format)
102102
/// <returns><see langword="true"/> if a match is found; otherwise, <see langword="false"/></returns>
103103
public bool TryFindFormatByFileExtension(string extension, [NotNullWhen(true)] out IImageFormat? format)
104104
{
105-
if (extension[0] == '.')
105+
if (!string.IsNullOrWhiteSpace(extension))
106106
{
107-
extension = extension[1..];
107+
if (extension[0] == '.')
108+
{
109+
extension = extension[1..];
110+
}
108111
}
109112

110113
format = this.imageFormats.FirstOrDefault(x =>

0 commit comments

Comments
 (0)