Hi,

this patch fixes <https://fedorahosted.org/freeipa/ticket/3323>.

Honza

--
Jan Cholasta
>From 9c8a97f8b1ae843679b4deda8b19e6026e532b32 Mon Sep 17 00:00:00 2001
From: Jan Cholasta <jchol...@redhat.com>
Date: Tue, 8 Jan 2013 16:32:41 +0100
Subject: [PATCH] Raise ValidationError on invalid CSV values.

https://fedorahosted.org/freeipa/ticket/3323
---
 ipalib/parameters.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index 670e036..63fa2f6 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -694,9 +694,16 @@ class Param(ReadOnly):
                                 delimiter=self.csv_separator, quotechar='"',
                                 skipinitialspace=self.csv_skipspace,
                                 **kwargs)
-        for row in csv_reader:
-            # decode UTF-8 back to Unicode, cell by cell:
-            yield [unicode(cell, 'utf-8') for cell in row]
+        try:
+            for row in csv_reader:
+                # decode UTF-8 back to Unicode, cell by cell:
+                yield [unicode(cell, 'utf-8') for cell in row]
+        except csv.Error, e:
+            raise ValidationError(
+                name=self.get_param_name(),
+                value=unicode_csv_data,
+                error=_("Improperly formatted CSV value (%s)" % e)
+            )
 
     def split_csv(self, value):
         """Split CSV strings into individual values.
-- 
1.8.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to