Page MenuHomePhorge

libkolab caldav client does not work if caldav server (eg. davical) outputs pretty-formatted xml (incorrect xml parsing)
Closed, ResolvedPublic

Description

While trying to connect kolab calendar plugin to a dabvical server, I could not get it working. I turned on dav_debug, and I realized that the problem is that davical outputs pretty formatted xml, with newlines and whitespaces, but libkolab caldav client does not parse it correctly; since it uses loadXML with no options, newlines and whitespaces result in:

  • parsed href urls having spaces and newlines in it, making the plugin fail to call the right urls
  • any element's childNodes being filled with empty "#text" nodes (see https://stackoverflow.com/a/22545712/3855992), making the plugin fail to parse the "real" nodes

The fix is simple and can be found in the stackoverflow answer above, even if the method indicated there is deprecated so the correct way is doing as follows:

if (!$doc->loadXML($xml, LIBXML_NOBLANKS)) {

and getting rid of the following line

$doc->formatOutput = true;

in plugins/libkolab/lib/kolab_dav_client.php

With that patch, I got it working.

Details

Ticket Type
Task