while trying to find a tool to export my contacts from my Baikal server, I stumbled upon an exception using the backup option of pyCardDAV:
Error Output
Traceback (most recent call last):
File "/home/tobias/git/pycarddav/bin/pc_query", line 138, in
query(conf)
File "/home/tobias/git/pycarddav/pycarddav/controllers/query.py", line 60, in query
action(my_dbtool, search_string, conf)
File "/home/tobias/git/pycarddav/pycarddav/controllers/query.py", line 79, in backup
vcf_file.write(vcard.vcf.encode('utf-8'))
File "/home/tobias/git/pycarddav/pycarddav/model.py", line 315, in vcf
collector.append(prop + types + ':' + line[0])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
Steps to Reproduce
Backup a vCard that contains a binary Photo and its encoding is stated by an uppercase 'b', e.g.:
I think i could track it down to a rather trivial problem and I propose the changes in this request as a solution.
In _model.vcard_fromstring(), the photo value is being decoded to binary by vobject.readOne(). The following call to _vcard_fromvobject() tries to encode it again.
I found that in _vcard_fromvobject(), the _line.ENCODINGparamlist call may return the encoding parameter as uppercase or lowercase 'b', depending on the entry in the given vCard. Therefore, the match for [u'b'] is not sufficient to catch those with 'B'-parameter, which causes that the value is not being encoded. This leads to the exception, e.g., when being written to a file.
Is there a particular reason, why vcard.serialize() method of vobject isn't used directly?
Related
In my opinion, this also solves the problem of #39, in which case the changes made in 07589c762582a75a977dae3cae3ce51f5c8e5c51 are no longer necessary.
Minor Point
I also found that, when backing up / exporting multiple contacts at once, entries are being concatenated immediately, resulting in
END:VCARDBEGIN:VCARD
lines in the output file. With this request, the vCards are separated by a newline character.
Hello,
while trying to find a tool to export my contacts from my Baikal server, I stumbled upon an exception using the backup option of pyCardDAV:
Error Output
Backup a vCard that contains a binary Photo and its encoding is stated by an uppercase 'b', e.g.:
I think i could track it down to a rather trivial problem and I propose the changes in this request as a solution.
In _model.vcard_fromstring(), the photo value is being decoded to binary by vobject.readOne(). The following call to _vcard_fromvobject() tries to encode it again.
I found that in _vcard_fromvobject(), the _line.ENCODINGparamlist call may return the encoding parameter as uppercase or lowercase 'b', depending on the entry in the given vCard. Therefore, the match for [u'b'] is not sufficient to catch those with 'B'-parameter, which causes that the value is not being encoded. This leads to the exception, e.g., when being written to a file.
Is there a particular reason, why vcard.serialize() method of vobject isn't used directly?
Related
In my opinion, this also solves the problem of #39, in which case the changes made in 07589c762582a75a977dae3cae3ce51f5c8e5c51 are no longer necessary.
Minor Point
I also found that, when backing up / exporting multiple contacts at once, entries are being concatenated immediately, resulting in
lines in the output file. With this request, the vCards are separated by a newline character.
Kind regards Tobias Röttger