Skip to content

Commit 73c8d8e

Browse files
committed
Merge remote-tracking branch 'origin/release/14.3' into release/14.3
2 parents 2d7c00f + d57d12d commit 73c8d8e

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed

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

Lines changed: 23 additions & 6 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;
@@ -48,16 +49,32 @@ public void Configure(ImageSharpMiddlewareOptions options)
4849
return Task.CompletedTask;
4950
}
5051

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

57-
int height = context.Parser.ParseValue<int>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Height), context.Culture);
58-
if (height <= 0 || height > _imagingSettings.Resize.MaxHeight)
66+
if (context.Commands.Contains(ResizeWebProcessor.Height))
5967
{
60-
context.Commands.Remove(ResizeWebProcessor.Height);
68+
if (!int.TryParse(
69+
context.Commands.GetValueOrDefault(ResizeWebProcessor.Height),
70+
NumberStyles.Integer,
71+
CultureInfo.InvariantCulture,
72+
out var height)
73+
|| height < 0
74+
|| height >= _imagingSettings.Resize.MaxHeight)
75+
{
76+
context.Commands.Remove(ResizeWebProcessor.Height);
77+
}
6178
}
6279

6380
return Task.CompletedTask;

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)