Skip to content

Commit d48470a

Browse files
Change media description length limit for remote media attachments from 1500 to 10000 characters (mastodon#37921)
1 parent 506d0af commit d48470a

6 files changed

Lines changed: 6 additions & 5 deletions

File tree

FEDERATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ The following table summarizes those limits.
6868
| Account `attributionDomains` | 256 | List will be truncated |
6969
| Account aliases (actor `alsoKnownAs`) | 256 | List will be truncated |
7070
| Custom emoji shortcode (`Emoji` `name`) | 2048 | Emoji will be rejected |
71-
| Media and avatar/header descriptions (`name`/`summary`) | 1500 | Description will be truncated |
71+
| Media and avatar/header descriptions (`name`/`summary`) | 10000 | Description will be truncated |
7272
| Collection name (`FeaturedCollection` `name`) | 256 | Name will be truncated |
7373
| Collection description (`FeaturedCollection` `summary`) | 2048 | Description will be truncated |

app/lib/activitypub/parser/media_attachment_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def thumbnail_remote_url
3030

3131
def description
3232
str = @json['summary'].presence || @json['name'].presence
33-
str = str.strip[0...MediaAttachment::MAX_DESCRIPTION_LENGTH] if str.present?
33+
str = str.strip[0...MediaAttachment::MAX_DESCRIPTION_HARD_LENGTH_LIMIT] if str.present?
3434
str
3535
end
3636

app/models/concerns/account/avatar.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def avatar_styles(file)
2525
validates_attachment_size :avatar, less_than: AVATAR_LIMIT
2626
remotable_attachment :avatar, AVATAR_LIMIT, suppress_errors: false
2727

28-
validates :avatar_description, length: { maximum: MediaAttachment::MAX_DESCRIPTION_LENGTH }
28+
validates :avatar_description, length: { maximum: MediaAttachment::MAX_DESCRIPTION_LENGTH }, if: -> { local? && will_save_change_to_avatar_description? }
2929
end
3030

3131
def avatar_original_url

app/models/concerns/account/header.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def header_styles(file)
2626
validates_attachment_size :header, less_than: HEADER_LIMIT
2727
remotable_attachment :header, HEADER_LIMIT, suppress_errors: false
2828

29-
validates :header_description, length: { maximum: MediaAttachment::MAX_DESCRIPTION_LENGTH }
29+
validates :header_description, length: { maximum: MediaAttachment::MAX_DESCRIPTION_LENGTH }, if: -> { local? && will_save_change_to_header_description? }
3030
end
3131

3232
def header_original_url

app/models/media_attachment.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class MediaAttachment < ApplicationRecord
3939
enum :processing, { queued: 0, in_progress: 1, complete: 2, failed: 3 }, prefix: true
4040

4141
MAX_DESCRIPTION_LENGTH = 1_500
42+
MAX_DESCRIPTION_HARD_LENGTH_LIMIT = 10_000
4243

4344
IMAGE_LIMIT = 16.megabytes
4445
VIDEO_LIMIT = 99.megabytes

app/services/activitypub/process_account_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def image_url_and_description(key)
238238
url = first_of_value(value['url'])
239239
url = url['href'] if url.is_a?(Hash)
240240
description = value['summary'].presence || value['name'].presence
241-
description = description.strip[0...MediaAttachment::MAX_DESCRIPTION_LENGTH] if description.present?
241+
description = description.strip[0...MediaAttachment::MAX_DESCRIPTION_HARD_LENGTH_LIMIT] if description.present?
242242
else
243243
url = value
244244
end

0 commit comments

Comments
 (0)