From bd05040133ec5ce5b431e05d8c873195d9501d6d Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 3 Nov 2022 14:38:06 +0100 Subject: [bugfix] Use []rune to check length of user-submitted text (#948) --- internal/api/client/app/appcreate.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'internal/api/client/app/appcreate.go') diff --git a/internal/api/client/app/appcreate.go b/internal/api/client/app/appcreate.go index 641357d42..c79c528d9 100644 --- a/internal/api/client/app/appcreate.go +++ b/internal/api/client/app/appcreate.go @@ -92,26 +92,26 @@ func (m *Module) AppsPOSTHandler(c *gin.Context) { return } - if len(form.ClientName) > formFieldLen { - err := fmt.Errorf("client_name must be less than %d bytes", formFieldLen) + if len([]rune(form.ClientName)) > formFieldLen { + err := fmt.Errorf("client_name must be less than %d characters", formFieldLen) api.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGet) return } - if len(form.RedirectURIs) > formRedirectLen { - err := fmt.Errorf("redirect_uris must be less than %d bytes", formRedirectLen) + if len([]rune(form.RedirectURIs)) > formRedirectLen { + err := fmt.Errorf("redirect_uris must be less than %d characters", formRedirectLen) api.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGet) return } - if len(form.Scopes) > formFieldLen { - err := fmt.Errorf("scopes must be less than %d bytes", formFieldLen) + if len([]rune(form.Scopes)) > formFieldLen { + err := fmt.Errorf("scopes must be less than %d characters", formFieldLen) api.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGet) return } - if len(form.Website) > formFieldLen { - err := fmt.Errorf("website must be less than %d bytes", formFieldLen) + if len([]rune(form.Website)) > formFieldLen { + err := fmt.Errorf("website must be less than %d characters", formFieldLen) api.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGet) return } -- cgit v1.2.3