Package: calypso
Version: 1.4
Severity: normal
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

When I imported a ics file which was utf-8 encoded and contained
non-ascii chars, I ended up with something which looked like double
encoding, both in the actual data and the git commit messages.

After asking a friend who actually speaks python, the situation seems
to be as follows:

- - vobject's serialize() method (in import_file) returns a str
- - the Item() constructor expects a Unicode object, and failing to get
  one like here, we run into the UnicodeDecodeError with the
  decode('latin1').encode('utf-8') fallback

(At least with python 2.7, there might be something different with
python 3.*.)

Converting the serialize output to utf-8 as in the attached patch
(which is against git HEAD, not the current debian package) seems to
fix the issue. At least importing my utf-8 calendar files works, I
haven't check what happens to other encodings.


Cheers,
gregor


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQJ8BAEBCgBmBQJU/Gf4XxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXREMUUxMzE2RTkzQTc2MEE4MTA0RDg1RkFC
QjNBNjgwMTg2NDlBQTA2AAoJELs6aAGGSaoGwa8P/iFniiRfANxYqwPlg+E55CrG
rAE1snkf5dZToGvVyytP9YV6vgvcVdBinUro9+9mVq8CD2zi54qQGMFbT3Mx645v
N9fztvXyDdPAMvw7OssH8ZOkzCjxwhhT2nKx+pP+etUQojfFmQsS5I5yFBJ0YnYV
HGlY2D9TBcAPdQPiWXsW4M4+DoJQk+GlI+NF9c+EFBmycKLa/lVT5N/vEJsPc9/b
ZM8BpMv4SE/EuubWn27oY2sNjkwtagTYBu9Bo847f4jX9Jh9vG9HAlsuVTawx8g6
gFQcf+BUaC1IuZNzSuQgmBKoIuasbTYomiXzMbaGFknpni7NhaZpfgbUzcs7xUyR
e/OqWn1riyozEO+m/Tw8mNhOFmEdoG6shKp/WXB5SpdT1JQyNjAcWbP+UXk9HAMW
SK9rTxjCo9UHXflOr+0as3ICM/rxeT1Pm+6BvU1k3+lpFtp+wLL0fdadCRqg1bir
/0gpd+n7xH0XS30MkyV0JyVdXuvSc6vAjQ4W0W8s9opPIDt1SWLUviYz/ByhZOLE
gbNBgbogCAMb02ky3OVf3oh3MyncfEk95rPgH4Ff7kMGqmG1j9fINKc0kVh23EMY
ULXjZkts79P5SRqykE+vcuwsq4yb6dys83FSNAqjjxAAsNrr+XmqQO6qlIegZfkt
NNX0enafTZtS2QXMQ3H/
=2lzk
-----END PGP SIGNATURE-----
diff --git a/calypso/webdav.py b/calypso/webdav.py
index 2292841..4f9ef1a 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -506,10 +506,11 @@ class Collection(object):
                     if ve.contents.has_key('dtstart') and ve.contents.has_key('duration'):
                         del ve.contents['duration']
                     new_ics.vevent_list = [ve]
-                    new_item = Item(new_ics.serialize(), None, path)
+                    # serialize returns a str, Item expects unicode
+                    new_item = Item(new_ics.serialize().decode('utf8'), None, path)
                     self.import_item(new_item, path)
             else:
-                new_item = Item(new_ics.serialize(), None, path)
+                new_item = Item(new_ics.serialize().decode('utf8'), None, path)
                 self.import_item(new_item, path)
             return True
         except Exception, ex:

Reply via email to