Created attachment 205028 [details]
Instead of unconditionally returning unicode, i check for the used charset with chardet.detect()
During syncing with an owncloud instance with the command:
one gets the following error, in case utf8 characters like Ä (German umlaut A) are included in a contact there will show the following crash:
Traceback (most recent call last):
File "/usr/local/bin/pycardsyncer", line 55, in <module>
File "/usr/local/lib/python2.7/site-packages/pycarddav/controllers/sync.py", line 57, in sync
my_dbtool.update(vcard, conf.account.name, href=href, etag=etag)
File "/usr/local/lib/python2.7/site-packages/pycarddav/backend.py", line 272, in update
stuple = (etag, vcard.name, vcard.fname, vcard_s, status, href, href)
File "/usr/local/lib/python2.7/site-packages/pycarddav/model.py", line 201, in name
return unicode(self['N']) if self['N'] else ''
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)
I assume, that the error is not owncloud specific. It is only necessary to have a changed contact
with an utf8 character in the Name.
I could fix the problem and the patch is in the appendix.
Thank you for the report and patch Oliver.
This looks like a good candidate to report (or PR) upstream, but having said that, this looks like upstream issue: https://github.com/geier/pycarddav/issues/127
There are two relevant (open) PR's:
https://github.com/geier/pycarddav/pull/124 (Nov 2018)
https://github.com/geier/pycarddav/pull/128 (Apr 2016)
The PR's have not been merged and the issue has not been closed. On that note, upstream has the following repository note:
DEPRECATED - use vdirsyncer & khard
And in the README:
This project is dead
pyCardDAV is deprecated. See the relevant issue. A good alternative is khard.
We should add DEPRECATED to this port with an EXPIRY_DATE, whether or not we resolve this specific issue with a ports-local patch
Created attachment 205321 [details]
svn diff to include Oliver's patch in the port
I have the problem when I test by adding a contact with UTF-8 in the name in Nextcloud. Oliver's patch work well.
PR #220368 is related to the deprecating problem. The port removal with DEPRECATED and EXPIRATION_DATE could provide a message to propose desktuils/py-khard as a replacement.
How longtime is acceptable to put in the EXPIRATION_DATE ?
I've added a diff in attachment to include Oliver's patch in the port.
Thank you Samir, could you please set maintainer-approval flag to + on the attachment/patch please
I've putted the flag
I just checked the upstream issue, and I'd probably take the pull request that fixes the issue:
@Samir Could you produce a patch adding this PR
@Oliver Could you test that patch once its produced to confirm it resolves the issue
Created attachment 205686 [details]
svn diff to include patch from Github
The patch in attachment, with the correction from Github. But when I try to use pc_query I have the following error :
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 12: ordinal not in range(128)
Which I don't have with Oliver patch