On 03/29/2012 12:20 AM, Rob Crittenden wrote:
I'm using a much narrower scope. I'm not trying to make it easy to
manage non-printable characters, just not blow things up if they exist.
Limiting to the XML-RPC supported set is for convenience, these are
unprintable characters in any context. This is just a two-fer.
Right. The XML set is a nice compromise when you want to define
“unprintable characters”.
Petr was right, I need to encode to unicode before doing this comparison
in order to compare invalid unicode characters so I moved that first.
I added a very basic unit test.
I suggest the attached additions to the test, to ensure the encoder uses
contains_non_printable as it should. (PEP8 nitpicks included)
If you're wondering where this data might come from, two ways are via AD
sync and migration.
Yes, the user will be left in a situation where they'll need to use
--setattr or ldapmodify to manage the data in the field. The UI doesn't
show the value at all but instead shows [object Object] (no errors in
console, not sure where this is coming from). It is possible to
highlight this and insert a new value though.
So basically, we don't allow non-printable characters in text fields.
When they're already there, we display weird data but don't blow up.
I believe that's fine, as long as it's documented.
--setattr won't work: the data won't make it through XML-RPC. (I get
Internal Server Error currently)
rob
--
Petr³
diff --git a/tests/test_ipalib/test_encoder.py b/tests/test_ipalib/test_encoder.py
index 78e4131..e37fb36 100644
--- a/tests/test_ipalib/test_encoder.py
+++ b/tests/test_ipalib/test_encoder.py
@@ -154,7 +154,9 @@ def test_non_printable(self):
o = self.cls()
for bad in [u'\x00', u'\x00 post', u'pre\x0b', u'pre \x00 post',
u'pre \x0e post', u'pre \uFFFE post', u'pre \x1b post']:
- assert(o.contains_non_printable(bad))
+ assert o.contains_non_printable(bad)
+ assert type(o.decode(bad.encode('utf-8'))) is str
for good in [u'\x32 post', u'pre\x0a', u'plain', u'pre \uFFFD post']:
- assert(o.contains_non_printable(good)) is False
+ assert not o.contains_non_printable(good)
+ assert type(o.decode(good.encode('utf-8'))) is unicode
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel