mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
Fix crash when encountering invalid account fields (#16598)
* Add test * Fix crash when encountering invalid account fields
This commit is contained in:
parent
c02d6c46e3
commit
4f852448e1
@ -295,7 +295,11 @@ class Account < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fields
|
def fields
|
||||||
(self[:fields] || []).map { |f| Field.new(self, f) }
|
(self[:fields] || []).map do |f|
|
||||||
|
Field.new(self, f)
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
|
end.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def fields_attributes=(attributes)
|
def fields_attributes=(attributes)
|
||||||
|
@ -12,6 +12,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||||||
attachment: [
|
attachment: [
|
||||||
{ type: 'PropertyValue', name: 'Pronouns', value: 'They/them' },
|
{ type: 'PropertyValue', name: 'Pronouns', value: 'They/them' },
|
||||||
{ type: 'PropertyValue', name: 'Occupation', value: 'Unit test' },
|
{ type: 'PropertyValue', name: 'Occupation', value: 'Unit test' },
|
||||||
|
{ type: 'PropertyValue', name: 'non-string', value: ['foo', 'bar'] },
|
||||||
],
|
],
|
||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user