summaryrefslogtreecommitdiff
path: root/internal/api/client
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/client')
-rw-r--r--internal/api/client/app/appcreate.go16
-rw-r--r--internal/api/client/media/mediacreate.go4
-rw-r--r--internal/api/client/media/mediaupdate.go4
-rw-r--r--internal/api/client/status/statuscreate.go12
4 files changed, 18 insertions, 18 deletions
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
}
diff --git a/internal/api/client/media/mediacreate.go b/internal/api/client/media/mediacreate.go
index 62f4a0d4e..dcaba5d5b 100644
--- a/internal/api/client/media/mediacreate.go
+++ b/internal/api/client/media/mediacreate.go
@@ -163,8 +163,8 @@ func validateCreateMedia(form *model.AttachmentRequest) error {
return fmt.Errorf("file size limit exceeded: limit is %d bytes but attachment was %d bytes", maxSize, form.File.Size)
}
- if 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 > 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)
}
return nil
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)
}
}
diff --git a/internal/api/client/status/statuscreate.go b/internal/api/client/status/statuscreate.go
index 13aa5d173..3b2ee1e05 100644
--- a/internal/api/client/status/statuscreate.go
+++ b/internal/api/client/status/statuscreate.go
@@ -124,8 +124,8 @@ func validateCreateStatus(form *model.AdvancedStatusCreateForm) error {
maxCwChars := config.GetStatusesCWMaxChars()
if form.Status != "" {
- if len(form.Status) > maxChars {
- return fmt.Errorf("status too long, %d characters provided but limit is %d", len(form.Status), maxChars)
+ if length := len([]rune(form.Status)); length > maxChars {
+ return fmt.Errorf("status too long, %d characters provided but limit is %d", length, maxChars)
}
}
@@ -141,15 +141,15 @@ func validateCreateStatus(form *model.AdvancedStatusCreateForm) error {
return fmt.Errorf("too many poll options provided, %d provided but limit is %d", len(form.Poll.Options), maxPollOptions)
}
for _, p := range form.Poll.Options {
- if len(p) > maxPollChars {
- return fmt.Errorf("poll option too long, %d characters provided but limit is %d", len(p), maxPollChars)
+ if length := len([]rune(p)); length > maxPollChars {
+ return fmt.Errorf("poll option too long, %d characters provided but limit is %d", length, maxPollChars)
}
}
}
if form.SpoilerText != "" {
- if len(form.SpoilerText) > maxCwChars {
- return fmt.Errorf("content-warning/spoilertext too long, %d characters provided but limit is %d", len(form.SpoilerText), maxCwChars)
+ if length := len([]rune(form.SpoilerText)); length > maxCwChars {
+ return fmt.Errorf("content-warning/spoilertext too long, %d characters provided but limit is %d", length, maxCwChars)
}
}