From aafdaf19fdd8c9dd2ec2d372df5e00b738b16739 Mon Sep 17 00:00:00 2001 From: sudokoko Date: Wed, 27 Mar 2024 23:50:23 -0400 Subject: [PATCH] Protect call to `ParseBase64Image` --- .../Pages/UserSettingsPage.cshtml.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml.cs index 2704e752..c1db9395 100644 --- a/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml.cs @@ -39,15 +39,13 @@ public class UserSettingsPage : BaseLayout if (!this.User.IsModerator && this.User != this.ProfileUser) return this.Redirect("~/user/" + userId); + // Deny request if in read-only mode + if (avatar != null && ServerConfiguration.Instance.UserGeneratedContentLimits.ReadOnlyMode) + return this.Redirect($"~/user/{userId}"); + string? avatarHash = await FileHelper.ParseBase64Image(avatar); - if (avatarHash != null) - { - // Deny request if in read-only mode - if (ServerConfiguration.Instance.UserGeneratedContentLimits.ReadOnlyMode) return this.Redirect($"~/user/{userId}"); - - this.ProfileUser.IconHash = avatarHash; - } + if (avatarHash != null) this.ProfileUser.IconHash = avatarHash; if (this.User.IsAdmin) this.ProfileUser.ProfileTag = profileTag;