From 92a6d04ba6abd43afdaa381e2d54bd99c7a1f9d0 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 9f19aee2ae..cbad56df63 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 2dfa3b955e..8aee15659f 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: