changeset 839:f8681a7fd834

memory (sqlite): the result of pickle.dumps in addToHistory must be encoded for the special characters to be stored.
author souliane <souliane@mailoo.org>
date Wed, 12 Feb 2014 21:46:48 +0100
parents 8829a6c0b070
children 58b4568ed4f2
files src/memory/sqlite.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/memory/sqlite.py	Wed Feb 12 15:24:03 2014 +0100
+++ b/src/memory/sqlite.py	Wed Feb 12 21:46:48 2014 +0100
@@ -190,9 +190,10 @@
         assert(profile)
         if extra is None:
             extra = {}
+        extra_ = pickle.dumps({k: v.encode('utf-8') for k, v in extra.items()}, 0).decode('utf-8')
         d = self.dbpool.runQuery("INSERT INTO history(source, source_res, dest, dest_res, timestamp, message, type, extra, profile_id) VALUES (?,?,?,?,?,?,?,?,?)",
                                  (from_jid.userhost(), from_jid.resource, to_jid.userhost(), to_jid.resource, timestamp or time(),
-                                  message, _type, pickle.dumps(extra, 0), self.profiles[profile]))
+                                  message, _type, extra_, self.profiles[profile]))
         d.addErrback(lambda ignore: error(_("Can't save following message in history: from [%(from_jid)s] to [%(to_jid)s] ==> [%(message)s]" %
                                           {"from_jid": from_jid.full(), "to_jid": to_jid.full(), "message": message})))
         return d