Skip to content

Commit

Permalink
Add sanitation
Browse files Browse the repository at this point in the history
  • Loading branch information
JimBobSquarePants committed Apr 4, 2022
1 parent ade3f94 commit 444faa1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ImageSharp.Web/ExifOrientationUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.

using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
Expand Down Expand Up @@ -64,6 +63,7 @@ public static Vector2 Transform(Vector2 position, Vector2 min, Vector2 max, usho
builder.AppendRotationDegrees(90);
break;
default:
// Use identity matrix.
break;
}

Expand Down
10 changes: 9 additions & 1 deletion src/ImageSharp.Web/Middleware/ImageSharpMiddlewareOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class ImageSharpMiddlewareOptions
}
// It's a good idea to have this to provide very basic security.
// We can safely use the static resize processor properties.
uint width = c.Parser.ParseValue<uint>(
c.Commands.GetValueOrDefault(ResizeWebProcessor.Width),
c.Culture);
Expand All @@ -40,6 +39,15 @@ public class ImageSharpMiddlewareOptions
c.Commands.Remove(ResizeWebProcessor.Height);
}
float[] coordinates = c.Parser.ParseValue<float[]>(c.Commands.GetValueOrDefault(ResizeWebProcessor.Xy), c.Culture);
if (coordinates.Length != 2
|| coordinates[1] < 0 || coordinates[1] > 1
|| coordinates[0] < 0 || coordinates[0] > 1)
{
c.Commands.Remove(ResizeWebProcessor.Xy);
}
return Task.CompletedTask;
};

Expand Down

0 comments on commit 444faa1

Please sign in to comment.