pimutils / pimutils/vdirsyncer

empty lines in events causes upload failures

Open
#1,026 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Python
Stars
1.9k
Forks
185
Avg merge
11h 49m
Merged PRs (30d)
1

Description

I guess the cause of this issue is a preexisting error on the source caldav servers calendar data assumably done by some faulty client implementation. But it annoyed the hell out of me as about 2 or 3 percent of the events failed to transfer between the two servers during a migration from a davical system to a nextcloud in a number of user calendars - so I started investigating.

It was always the same error: 415 'Unsupported Media Type'

Digging through some example events revealed an error in the SUMMARY attribute. Those where multiline entries with blank lines in it and each of the faulty ones contained a complete empty line, not just a line with a leading space followed by a newline.
Removing those empty lines solved the issue with those events, but to handle the whole migration without having to handle each error by hand would either mean to dump the whole thing to files, fix the broken ones and upload the bunch to the new system, or modifying the vdirsyncer code - I decided to try the latter.

Before doing a pull request i would like to discuss the matter here, if this special case is worth changing the code and if what i did might have some unforeseen side effects.
As I understand the RFC, neither ics nor vcard objects should contain blank lines, at least not those without at least a space indicating that its part of the previous attribute. So my guess is, that the item import could securely remove those lines from the raw data. At least in my tests that seemed to work.

As a reference, I replaced in vobject.py class Item: the following in the __init__ function:

- self._raw = raw
+ self._raw = "".join([l for l in raw.strip().splitlines(True) if l.strip('\r\n') ])

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in vobject.py at class Item and its __init__ method, then inspect the surrounding parsing and import flow. Reproduce an event containing a truly empty line in its SUMMARY and verify that the migration succeeds without changing valid folded lines or other calendar and contact data.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.