Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CommonImageActions.AspNetCore/CommonImageActionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public string PathToWatch

public static string DefaultDiskCacheLocation { get; set; }

public static int MaxUrlWidth { get; set; } = 5000;

public static int MaxUrlHeight { get; set; } = 5000;

public static string[] ValidImageExtensions = {
".bmp",
".gif",
Expand Down
12 changes: 10 additions & 2 deletions CommonImageActions.AspNetCore/CommonImageActionsMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,21 @@ public static ImageActions ConvertQueryStringToImageActions(string queryString,
var widthString = query["width"] ?? query["w"];
if (int.TryParse(widthString, out int width))
{
imageActions.Width = width;
//sanity check to make sure no bad actor requests a number that may eat all the ram in the system
if(width < CommonImageActionSettings.MaxUrlWidth)
{
imageActions.Width = width;
}
}

var heightString = query["height"] ?? query["h"];
if (int.TryParse(heightString, out int height))
{
imageActions.Height = height;
//sanity check to make sure no bad actor requests a number that may eat all the ram in the system
if (width < CommonImageActionSettings.MaxUrlHeight)
{
imageActions.Height = height;
}
}

var pageString = query["Page"] ?? query["p"];
Expand Down
Loading