aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2017-11-17 06:24:49 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2017-11-23 08:57:45 +0100
commitedc44d613bdc57566a48ea855af86a9df0b3d13d (patch)
tree7526e59d42152d7b36be904217980f6a451ba25c /contrib
parent16e7aecd29ad0e7f59cdd7a241ae54d3b5b05dc9 (diff)
downloadcalcurse-edc44d613bdc57566a48ea855af86a9df0b3d13d.tar.gz
calcurse-edc44d613bdc57566a48ea855af86a9df0b3d13d.zip
calcurse-caldav: Avoid corrupting the sync DB
When importing an iCal event via calcurse fails (i.e. does not return a single object hash), do not write anything to the synchronization database instead of blindly appending the entry, thereby potentially corrupting the database. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/caldav/calcurse-caldav.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py
index 4d5e471..997a5f6 100755
--- a/contrib/caldav/calcurse-caldav.py
+++ b/contrib/caldav/calcurse-caldav.py
@@ -431,8 +431,15 @@ def pull_objects(hrefs_missing, hrefs_modified, conn, syncdb, etagdict):
continue
objhash = calcurse_import(cdata)
- syncdb_add(syncdb, href, etag, objhash)
- added += 1
+
+ # TODO: Add support for importing multiple events at once, see GitHub
+ # issue #20 for details.
+ if re.match(r'[0-ga-f]+$', objhash):
+ syncdb_add(syncdb, href, etag, objhash)
+ added += 1
+ else:
+ print("Failed to import object: {} ({})".format(etag, href),
+ file=sys.stderr)
return added