|
| 1 | +using System.Globalization; |
1 | 2 | using Microsoft.AspNetCore.Http; |
2 | 3 | using Microsoft.AspNetCore.Http.Headers; |
3 | 4 | using Microsoft.Extensions.Options; |
@@ -48,16 +49,26 @@ public void Configure(ImageSharpMiddlewareOptions options) |
48 | 49 | return Task.CompletedTask; |
49 | 50 | } |
50 | 51 |
|
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)) |
53 | 53 | { |
54 | | - context.Commands.Remove(ResizeWebProcessor.Width); |
| 54 | + if (!int.TryParse(context.Commands.GetValueOrDefault(ResizeWebProcessor.Width), NumberStyles.Integer, |
| 55 | + CultureInfo.InvariantCulture, out var width) |
| 56 | + || width < 0 |
| 57 | + || width >= _imagingSettings.Resize.MaxWidth) |
| 58 | + { |
| 59 | + context.Commands.Remove(ResizeWebProcessor.Width); |
| 60 | + } |
55 | 61 | } |
56 | 62 |
|
57 | | - int height = context.Parser.ParseValue<int>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Height), context.Culture); |
58 | | - if (height <= 0 || height > _imagingSettings.Resize.MaxHeight) |
| 63 | + if (context.Commands.Contains(ResizeWebProcessor.Height)) |
59 | 64 | { |
60 | | - context.Commands.Remove(ResizeWebProcessor.Height); |
| 65 | + if (!int.TryParse(context.Commands.GetValueOrDefault(ResizeWebProcessor.Height), NumberStyles.Integer, |
| 66 | + CultureInfo.InvariantCulture, out var height) |
| 67 | + || height < 0 |
| 68 | + || height >= _imagingSettings.Resize.MaxHeight) |
| 69 | + { |
| 70 | + context.Commands.Remove(ResizeWebProcessor.Height); |
| 71 | + } |
61 | 72 | } |
62 | 73 |
|
63 | 74 | return Task.CompletedTask; |
|
0 commit comments