diff options
author | Tobias Brox <tobias@redpill-linpro.com> | 2021-09-16 15:18:43 +0200 |
---|---|---|
committer | Tobias Brox <tobias@redpill-linpro.com> | 2021-09-16 15:18:43 +0200 |
commit | dea36c80e4fc0e6a8be1f38f93ed17efc8733bfe (patch) | |
tree | 9218479a9b64ea973985750c6f26b8be39e42927 | |
parent | b3c13f079851a7ae413a08ee0ea4d08e8a265dac (diff) | |
download | python-caldav-dea36c80e4fc0e6a8be1f38f93ed17efc8733bfe.zip |
Fixing up broken ical by stripping whitespaces. Possible fix for https://github.com/python-caldav/caldav/issues/37
-rw-r--r-- | caldav/lib/vcal.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/caldav/lib/vcal.py b/caldav/lib/vcal.py index aa92f46..f0e2cf4 100644 --- a/caldav/lib/vcal.py +++ b/caldav/lib/vcal.py @@ -39,6 +39,12 @@ def fix(event): 3) iCloud apparently duplicates the DTSTAMP property sometimes - keep the first DTSTAMP encountered (arguably the DTSTAMP with earliest value should be kept). + + 4) ref https://github.com/python-caldav/caldav/issues/37, + X-APPLE-STRUCTURED-EVENT attribute sometimes comes with trailing + white space. I've decided to remove all trailing spaces, since + they seem to cause a traceback with vobject and those lines are + simply ignored by icalendar. """ ## TODO: add ^ before COMPLETED and CREATED? ## 1) Add a random time if completed is given as date @@ -51,10 +57,13 @@ def fix(event): 'CREATED:19700101T000000Z', fixed) fixed = re.sub(r"\\+('\")", r"\1", fixed) - fixed2 = "" + ## 4) trailing whitespace probably never makes sense + fixed = re.sub(' *$', '', fixed) + ## 3 fix duplicated DTSTAMP ## OPTIMIZATION TODO: use list and join rather than concatination ## remove duplication of DTSTAMP + fixed2 = "" for line in fixed.strip().split('\n'): if line.startswith('BEGIN:V'): cnt = 0 |