From 317ec06dc791bfbd9eb86177b3027ca92d683b8b Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 28 Oct 2022 23:30:44 +0200 Subject: [PATCH] Fix error when uploading malformed CSV import (#19509) --- app/validators/import_validator.rb | 2 ++ config/locales/activerecord.en.yml | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/app/validators/import_validator.rb b/app/validators/import_validator.rb index 9f19aee2aec..cbad56df63b 100644 --- a/app/validators/import_validator.rb +++ b/app/validators/import_validator.rb @@ -26,6 +26,8 @@ class ImportValidator < ActiveModel::Validator when 'following' validate_following_import(import, row_count) end + rescue CSV::MalformedCSVError + import.errors.add(:data, :malformed) end private diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml index 2dfa3b955ef..8aee15659f2 100644 --- a/config/locales/activerecord.en.yml +++ b/config/locales/activerecord.en.yml @@ -29,6 +29,10 @@ en: attributes: website: invalid: is not a valid URL + import: + attributes: + data: + malformed: is malformed status: attributes: reblog: