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/media/mediaupdate.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'internal/api/client/media/mediaupdate.go') diff --git a/internal/api/client/media/mediaupdate.go b/internal/api/client/media/mediaupdate.go index fb0e67ddc..438eaca23 100644 --- a/internal/api/client/media/mediaupdate.go +++ b/internal/api/client/media/mediaupdate.go @@ -142,8 +142,8 @@ func validateUpdateMedia(form *model.AttachmentUpdateRequest) error { maxDescriptionChars := config.GetMediaDescriptionMaxChars() if form.Description != nil { - if len(*form.Description) < minDescriptionChars || len(*form.Description) > maxDescriptionChars { - return fmt.Errorf("image description length must be between %d and %d characters (inclusive), but provided image description was %d chars", minDescriptionChars, maxDescriptionChars, len(*form.Description)) + if length := len([]rune(*form.Description)); length < minDescriptionChars || length > maxDescriptionChars { + return fmt.Errorf("image description length must be between %d and %d characters (inclusive), but provided image description was %d chars", minDescriptionChars, maxDescriptionChars, length) } } -- cgit v1.2.3