diff options
author | Pavel Zuna <pzuna@redhat.com> | 2009-07-31 18:01:01 +0200 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2009-08-03 23:00:17 -0600 |
commit | b20c69dec73cbacd43b9ca0b926fd267c8839407 (patch) | |
tree | ca75eaa54c4fe5b95cae7fe522cc3735cff83e32 /ipalib | |
parent | 104d02e16745bd237505afdac02ba6cdb4ec25fa (diff) | |
download | freeipa-b20c69dec73cbacd43b9ca0b926fd267c8839407.tar.gz freeipa-b20c69dec73cbacd43b9ca0b926fd267c8839407.tar.xz freeipa-b20c69dec73cbacd43b9ca0b926fd267c8839407.zip |
Prevent double encoding/decoding when processing compound types.
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/encoder.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/ipalib/encoder.py b/ipalib/encoder.py index 9d9d735a..22bc54c7 100644 --- a/ipalib/encoder.py +++ b/ipalib/encoder.py @@ -57,10 +57,11 @@ class Encoder(object): def _decode_dict_val(self, key, val): f = self.encoder_settings.decode_dict_vals_table.get( - self.encoder_settings.decode_dict_vals_table_keygen(key, val), - self.decode + self.encoder_settings.decode_dict_vals_table_keygen(key, val) ) - return f(val) + if f: + return val + return self.decode(val) def encode(self, var): """ @@ -70,7 +71,9 @@ class Encoder(object): Returns an encoded copy of 'var'. """ - if isinstance(var, basestring): + if isinstance(var, str): + return var + elif isinstance(var, unicode): return self.encoder_settings.encode_postprocessor( var.encode(self.encoder_settings.encode_to) ) @@ -122,7 +125,9 @@ class Encoder(object): Returns a decoded copy of 'var'. """ - if isinstance(var, basestring): + if isinstance(var, unicode): + return var + elif isinstance(var, str): return self.encoder_settings.decode_postprocessor( var.decode(self.encoder_settings.decode_from) ) |