From dd6ce5c39506e9e22aeefa4db34ac8caa48a5cdd Mon Sep 17 00:00:00 2001 From: whoswhip Date: Mon, 29 Dec 2025 04:25:35 -0500 Subject: [PATCH] feat: improve paste creation validation; add content size check and remove unnecessary logging --- SharpbinV3/Controllers/PasteController.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/SharpbinV3/Controllers/PasteController.cs b/SharpbinV3/Controllers/PasteController.cs index 25239c1..0a63573 100644 --- a/SharpbinV3/Controllers/PasteController.cs +++ b/SharpbinV3/Controllers/PasteController.cs @@ -30,14 +30,11 @@ namespace SharpbinV3.Server.Controllers return BadRequest(new { message = $"Invalid title. Must be less than {_pasteSettings.MaxTitleLength} characters." }); string content = await new StreamReader(Request.Body).ReadToEndAsync(); + if (System.Text.Encoding.UTF8.GetByteCount(content) > _pasteSettings.MaxPasteSizeInBytes) + return BadRequest(new { message = $"Paste size exceeds the maximum allowed size of {_pasteSettings.MaxPasteSizeInBytes} bytes." }); var httpUser = HttpContext.User; - foreach (var key in httpUser.Claims) - { - Console.WriteLine($"Claim: {key.Type} = {key.Value}"); - } var userUUID = httpUser?.FindFirst("UUID")?.Value; User? user = userUUID is not null ? await _userService.GetByUUID(Guid.Parse(userUUID)) : null; - Console.WriteLine($"Creating paste for user: {(user != null ? user.Username : "Anonymous")}"); Paste paste = await _pasteService.Create(user, content, title, syntax, visibility, expiresAt); return Ok(new {