Skip to content

Commit 262fe3b

Browse files
ClearlyClairekadoshita
authored andcommitted
Fix crash when encountering invalid account fields (mastodon#16598)
* Add test * Fix crash when encountering invalid account fields
1 parent 031ea85 commit 262fe3b

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
@@ -295,7 +295,11 @@ def also_known_as
295295
end
296296

297297
def fields
298-
(self[:fields] || []).map { |f| Field.new(self, f) }
298+
(self[:fields] || []).map do |f|
299+
Field.new(self, f)
300+
rescue
301+
nil
302+
end.compact
299303
end
300304

301305
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)