mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-31 05:36:14 -06:00
apply review feedback
This commit is contained in:
parent
9b1683bee6
commit
263ddf8128
3 changed files with 21 additions and 26 deletions
|
|
@ -44,11 +44,12 @@ func (p *Processor) EmojiCreate(
|
|||
) (*apimodel.Emoji, gtserror.WithCode) {
|
||||
|
||||
// Get maximum supported local emoji size.
|
||||
maxsz := int64(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
maxsz := config.GetMediaEmojiLocalMaxSize()
|
||||
maxszInt64 := int64(maxsz) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if form.Image.Size > maxsz {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %d", maxsz)
|
||||
if form.Image.Size > maxszInt64 {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %s", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ func (p *Processor) EmojiCreate(
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxszInt64)
|
||||
data := func(context.Context) (io.ReadCloser, error) {
|
||||
return rc, nil
|
||||
}
|
||||
|
|
@ -299,11 +300,12 @@ func (p *Processor) emojiUpdateCopy(
|
|||
}
|
||||
|
||||
// Get maximum supported local emoji size.
|
||||
maxsz := int(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated
|
||||
maxsz := config.GetMediaEmojiLocalMaxSize()
|
||||
maxszInt := int(maxsz) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure target emoji image within size bounds.
|
||||
if target.ImageFileSize > maxsz {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %d", maxsz)
|
||||
if target.ImageFileSize > maxszInt {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %s", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
|
@ -440,11 +442,12 @@ func (p *Processor) emojiUpdateModify(
|
|||
// We can do both at the same time :)
|
||||
|
||||
// Get maximum supported local emoji size.
|
||||
maxsz := int64(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
maxsz := config.GetMediaEmojiLocalMaxSize()
|
||||
maxszInt64 := int64(maxsz) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if image.Size > maxsz {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %d", maxsz)
|
||||
if image.Size > maxszInt64 {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %s", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
|
@ -456,7 +459,7 @@ func (p *Processor) emojiUpdateModify(
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz)) // #nosec G115 -- Already validated.
|
||||
data := func(context.Context) (io.ReadCloser, error) {
|
||||
return rc, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue