commit 7dc3a63231387f8ee61890d8aeac914d5b65011f
parent 362f79692392bd8a36e0babea9fcfd57d13318c2
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Wed, 5 Apr 2023 16:24:47 -0700
fix regex
Diffstat:
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pkg/web/handlers/admin.go b/pkg/web/handlers/admin.go
@@ -568,7 +568,7 @@ func AdminEditUserHandler(c echo.Context) error {
data.Vetted = utils.DoParseBool(c.FormValue("vetted"))
data.CollectMetadata = utils.DoParseBool(c.FormValue("collect_metadata"))
data.ChatColor = c.FormValue("chat_color")
- colorRgx := regexp.MustCompile(`#[0-9a-f]{6}`)
+ colorRgx := regexp.MustCompile(`^#[0-9a-f]{6}$`)
if !colorRgx.MatchString(data.ChatColor) {
data.Errors.Username = "Invalid color format"
}
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -3103,7 +3103,7 @@ func changeSettingsForm(c echo.Context, data settingsChatData) error {
//data.NotifyNewMessageSound = utils.DoParseInt64(c.Request().PostFormValue("notify_new_message_sound"))
//data.NotifyTaggedSound = utils.DoParseInt64(c.Request().PostFormValue("notify_tagged_sound"))
//data.NotifyPmmedSound = utils.DoParseInt64(c.Request().PostFormValue("notify_pmmed_sound"))
- colorRgx := regexp.MustCompile(`#[0-9a-f]{6}`)
+ colorRgx := regexp.MustCompile(`^#[0-9a-f]{6}$`)
if !colorRgx.MatchString(data.ChatColor) {
data.Error = "Invalid color format"
return c.Render(http.StatusOK, "settings.chat", data)