Skip to content

Commit d57d12d

Browse files
committed
Fixed imagesharp 2 also
1 parent 4660490 commit d57d12d

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/Umbraco.Cms.Imaging.ImageSharp2/ConfigureImageSharpMiddlewareOptions.cs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Globalization;
12
using Microsoft.AspNetCore.Http;
23
using Microsoft.AspNetCore.Http.Headers;
34
using Microsoft.Extensions.Options;
@@ -47,20 +48,32 @@ public void Configure(ImageSharpMiddlewareOptions options)
4748
return Task.CompletedTask;
4849
}
4950

50-
var width = context.Parser.ParseValue<int>(
51-
context.Commands.GetValueOrDefault(ResizeWebProcessor.Width),
52-
context.Culture);
53-
if (width <= 0 || width > _imagingSettings.Resize.MaxWidth)
51+
if (context.Commands.Contains(ResizeWebProcessor.Width))
5452
{
55-
context.Commands.Remove(ResizeWebProcessor.Width);
53+
if (!int.TryParse(
54+
context.Commands.GetValueOrDefault(ResizeWebProcessor.Width),
55+
NumberStyles.Integer,
56+
CultureInfo.InvariantCulture,
57+
out var width)
58+
|| width < 0
59+
|| width >= _imagingSettings.Resize.MaxWidth)
60+
{
61+
context.Commands.Remove(ResizeWebProcessor.Width);
62+
}
5663
}
5764

58-
var height = context.Parser.ParseValue<int>(
59-
context.Commands.GetValueOrDefault(ResizeWebProcessor.Height),
60-
context.Culture);
61-
if (height <= 0 || height > _imagingSettings.Resize.MaxHeight)
65+
if (context.Commands.Contains(ResizeWebProcessor.Height))
6266
{
63-
context.Commands.Remove(ResizeWebProcessor.Height);
67+
if (!int.TryParse(
68+
context.Commands.GetValueOrDefault(ResizeWebProcessor.Height),
69+
NumberStyles.Integer,
70+
CultureInfo.InvariantCulture,
71+
out var height)
72+
|| height < 0
73+
|| height >= _imagingSettings.Resize.MaxHeight)
74+
{
75+
context.Commands.Remove(ResizeWebProcessor.Height);
76+
}
6477
}
6578

6679
return Task.CompletedTask;

0 commit comments

Comments
 (0)