Ensure case-insensitive fields are converted to lowercase in user imports (#29740)

This commit is contained in:
Emelia Smith 2024-03-26 10:30:10 +01:00 committed by GitHub
parent a3e8b78250
commit eb926b7e60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -111,12 +111,14 @@ class Form::Import
csv_converter = lambda do |field, field_info| csv_converter = lambda do |field, field_info|
case field_info.header case field_info.header
when 'Show boosts', 'Notify on new posts', 'Hide notifications' when 'Show boosts', 'Notify on new posts', 'Hide notifications'
ActiveModel::Type::Boolean.new.cast(field) ActiveModel::Type::Boolean.new.cast(field&.downcase)
when 'Languages' when 'Languages'
field&.split(',')&.map(&:strip)&.presence field&.split(',')&.map(&:strip)&.presence
when 'Account address' when 'Account address'
field.strip.gsub(/\A@/, '') field.strip.gsub(/\A@/, '')
when '#domain', '#uri', 'List name' when '#domain'
field&.strip&.downcase
when '#uri', 'List name'
field.strip field.strip
else else
field field