lambdabaa / dav

WebDAV, CalDAV, and CardDAV client for nodejs and the browser.
Mozilla Public License 2.0
304 stars 71 forks source link

test(caldav): multiple props in calendarQuery #154

Open hairmare opened 3 years ago

hairmare commented 3 years ago

The buggy behaviour when passing multiple props is that they get mapped to the final XML string with a , separator.

⚠️ This is a bug-report-in-form-of-a-test rather than a direct contribution.

Example

I have been mucking about with the low-level API for no good reason and tried to use dav.request.calendarQuery (and by extension dav.template.caledarQuery?) with invalid results.

dav = require('dav')

xhr = new dav.transport.Transport(new dav.Credentials())
client = new dav.Client(xhr)
req = dav.request.calendarQuery({
  props: [
    { name: 'catdog', namespace: dav.ns.DAV },
    { name: 'winslow', namespace: dav.ns.CALDAV },
  ],
})
client.send(req, 'https://example.org/remote.php/dav/calendars/user/calname')

Observed Results

The sent XML is invalid due to a comma:

    <d:prop>
      <d:catdog />,<c:winslow />
    </d:prop>

Expected Results

The XML should not contain a comma between the props:

    <d:prop>
      <d:catdog /><c:winslow />
    </d:prop>

More Info

The endpoint in question is an ownCloud instance which is why I'm even trying to do it via low-level code 🙄.

I didn't figure out a proper fix but hope that the included test will help narrow down the issue for someone better versed in the code base.