Skip to content

Commit 80ca4fd

Browse files
committed
Fix crash when encountering invalid account fields (mastodon#16598)
* Add test * Fix crash when encountering invalid account fields
1 parent 168272f commit 80ca4fd

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

app/models/account.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ def also_known_as
302302
end
303303

304304
def fields
305-
(self[:fields] || []).map { |f| Field.new(self, f) }
305+
(self[:fields] || []).map do |f|
306+
Field.new(self, f)
307+
rescue
308+
nil
309+
end.compact
306310
end
307311

308312
def fields_attributes=(attributes)

spec/services/activitypub/process_account_service_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
attachment: [
1313
{ type: 'PropertyValue', name: 'Pronouns', value: 'They/them' },
1414
{ type: 'PropertyValue', name: 'Occupation', value: 'Unit test' },
15+
{ type: 'PropertyValue', name: 'non-string', value: ['foo', 'bar'] },
1516
],
1617
}.with_indifferent_access
1718
end

0 commit comments

Comments
 (0)