From f5e881e0e40e9f7a28550f01394113022124ccc2 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sun, 26 Jun 2022 03:01:19 +0100 Subject: [PATCH] Add length check for username. --- src/main/java/me/kavin/piped/utils/ResponseHelper.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index 8548c4c..7bdf47c 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -633,6 +633,12 @@ public class ResponseHelper { if (StringUtils.isBlank(user) || StringUtils.isBlank(pass)) return mapper.writeValueAsBytes(new InvalidRequestResponse()); + if (user.length() > 24) + return mapper.writeValueAsBytes( + mapper.createObjectNode() + .put("error", "The username must be less than 24 characters") + ); + user = user.toLowerCase(); try (Session s = DatabaseSessionFactory.createSession()) {