Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/14.3' into release/14.3
Browse files Browse the repository at this point in the history
  • Loading branch information
iOvergaard committed Sep 30, 2024
2 parents 2d7c00f + d57d12d commit 73c8d8e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Headers;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -48,16 +49,32 @@ public void Configure(ImageSharpMiddlewareOptions options)
return Task.CompletedTask;
}

int width = context.Parser.ParseValue<int>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Width), context.Culture);
if (width <= 0 || width > _imagingSettings.Resize.MaxWidth)
if (context.Commands.Contains(ResizeWebProcessor.Width))
{
context.Commands.Remove(ResizeWebProcessor.Width);
if (!int.TryParse(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Width),
NumberStyles.Integer,
CultureInfo.InvariantCulture,
out var width)
|| width < 0
|| width >= _imagingSettings.Resize.MaxWidth)
{
context.Commands.Remove(ResizeWebProcessor.Width);
}
}

int height = context.Parser.ParseValue<int>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Height), context.Culture);
if (height <= 0 || height > _imagingSettings.Resize.MaxHeight)
if (context.Commands.Contains(ResizeWebProcessor.Height))
{
context.Commands.Remove(ResizeWebProcessor.Height);
if (!int.TryParse(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Height),
NumberStyles.Integer,
CultureInfo.InvariantCulture,
out var height)
|| height < 0
|| height >= _imagingSettings.Resize.MaxHeight)
{
context.Commands.Remove(ResizeWebProcessor.Height);
}
}

return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Headers;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -47,20 +48,32 @@ public void Configure(ImageSharpMiddlewareOptions options)
return Task.CompletedTask;
}

var width = context.Parser.ParseValue<int>(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Width),
context.Culture);
if (width <= 0 || width > _imagingSettings.Resize.MaxWidth)
if (context.Commands.Contains(ResizeWebProcessor.Width))
{
context.Commands.Remove(ResizeWebProcessor.Width);
if (!int.TryParse(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Width),
NumberStyles.Integer,
CultureInfo.InvariantCulture,
out var width)
|| width < 0
|| width >= _imagingSettings.Resize.MaxWidth)
{
context.Commands.Remove(ResizeWebProcessor.Width);
}
}

var height = context.Parser.ParseValue<int>(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Height),
context.Culture);
if (height <= 0 || height > _imagingSettings.Resize.MaxHeight)
if (context.Commands.Contains(ResizeWebProcessor.Height))
{
context.Commands.Remove(ResizeWebProcessor.Height);
if (!int.TryParse(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Height),
NumberStyles.Integer,
CultureInfo.InvariantCulture,
out var height)
|| height < 0
|| height >= _imagingSettings.Resize.MaxHeight)
{
context.Commands.Remove(ResizeWebProcessor.Height);
}
}

return Task.CompletedTask;
Expand Down

0 comments on commit 73c8d8e

Please sign in to comment.