Skip to content

Commit

Permalink
Fix crash when encountering invalid account fields (mastodon#16598)
Browse files Browse the repository at this point in the history
* Add test

* Fix crash when encountering invalid account fields
  • Loading branch information
ClearlyClaire authored and chasedream1129 committed Aug 12, 2021
1 parent 6d0cac9 commit ec3cafc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,11 @@ def also_known_as
end

def fields
(self[:fields] || []).map { |f| Field.new(self, f) }
(self[:fields] || []).map do |f|
Field.new(self, f)
rescue
nil
end.compact
end

def fields_attributes=(attributes)
Expand Down
1 change: 1 addition & 0 deletions spec/services/activitypub/process_account_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
attachment: [
{ type: 'PropertyValue', name: 'Pronouns', value: 'They/them' },
{ type: 'PropertyValue', name: 'Occupation', value: 'Unit test' },
{ type: 'PropertyValue', name: 'non-string', value: ['foo', 'bar'] },
],
}.with_indifferent_access
end
Expand Down

0 comments on commit ec3cafc

Please sign in to comment.