diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-08-11 16:40:55 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-01-28 22:53:15 +0100 |
commit | 80ca4fdb3c6fb23d20213b075ccf59106e0e3129 (patch) | |
tree | 296644a11a4928f87be5b82fa83af5f978325d55 | |
parent | 168272fe610f9b43b0efff9d5d4a1860e466a387 (diff) |
Fix crash when encountering invalid account fields (#16598)
* Add test
* Fix crash when encountering invalid account fields
-rw-r--r-- | app/models/account.rb | 6 | ||||
-rw-r--r-- | spec/services/activitypub/process_account_service_spec.rb | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 007adc409bc..089727529a8 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -302,7 +302,11 @@ class Account < ApplicationRecord 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) diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 56e7f83211b..1b1d878a7e6 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -12,6 +12,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do 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 |