Skip to content

Commit 444faa1

Browse files
Add sanitation
1 parent ade3f94 commit 444faa1

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/ImageSharp.Web/ExifOrientationUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

4-
using System;
54
using System.Numerics;
65
using System.Runtime.CompilerServices;
76
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
@@ -64,6 +63,7 @@ public static Vector2 Transform(Vector2 position, Vector2 min, Vector2 max, usho
6463
builder.AppendRotationDegrees(90);
6564
break;
6665
default:
66+
// Use identity matrix.
6767
break;
6868
}
6969

src/ImageSharp.Web/Middleware/ImageSharpMiddlewareOptions.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public class ImageSharpMiddlewareOptions
2525
}
2626

2727
// It's a good idea to have this to provide very basic security.
28-
// We can safely use the static resize processor properties.
2928
uint width = c.Parser.ParseValue<uint>(
3029
c.Commands.GetValueOrDefault(ResizeWebProcessor.Width),
3130
c.Culture);
@@ -40,6 +39,15 @@ public class ImageSharpMiddlewareOptions
4039
c.Commands.Remove(ResizeWebProcessor.Height);
4140
}
4241

42+
float[] coordinates = c.Parser.ParseValue<float[]>(c.Commands.GetValueOrDefault(ResizeWebProcessor.Xy), c.Culture);
43+
44+
if (coordinates.Length != 2
45+
|| coordinates[1] < 0 || coordinates[1] > 1
46+
|| coordinates[0] < 0 || coordinates[0] > 1)
47+
{
48+
c.Commands.Remove(ResizeWebProcessor.Xy);
49+
}
50+
4351
return Task.CompletedTask;
4452
};
4553

0 commit comments

Comments
 (0)