Skip to content

Commit

Permalink
catch 'broken' vcards
Browse files Browse the repository at this point in the history
broken in a sense that vobject cannot parse them
these cards won't get inserted into the db, but instead a warning is
printed and, in debug mode, the whole vcard is printed.

this should 'take care' of cases like gh #78 for now
  • Loading branch information
geier committed Sep 3, 2013
1 parent eabf4b4 commit 7308c90
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pycarddav/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,15 @@ def update(self, vcard, account_name, href='', etag='', status=OK):
vcard_s = vcard.decode('utf-8')
except UnicodeEncodeError:
vcard_s = vcard # incase it's already unicode and py2
vcard = model.vcard_from_string(vcard)
try:
vcard = model.vcard_from_string(vcard)
except:
logging.error('VCard {0} could not be inserted into the '
'db'.format(href))
if self.debug:
logging.error('could not be converted to vcard')
logging.error(vcard)
return
else:
vcard_s = vcard.vcf
if href == '':
Expand Down

0 comments on commit 7308c90

Please sign in to comment.