mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-06 02:23:16 -06:00
[bugfix] Use []rune to check length of user-submitted text (#948)
This commit is contained in:
parent
f3fc040c2e
commit
bd05040133
6 changed files with 40 additions and 32 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue