328 Commits

Author SHA1 Message Date
Jay Hemnani
2b106fb99b webdav: fix LocalFileSystem.Copy for directories
The walk ignored the path of each entry: it created dstPath for every directory
and copied srcPath to dstPath for every file, so copying a non-empty directory
failed with "open: is a directory". With Overwrite the destination had already
been removed, so its files were lost. Copy each entry to its own path under the
destination.
2026-11-18 21:18:25 +01:00
Simon Ser
bf63772263 carddav: make malformed address object data non-fatal in client
Same as 8ddea980d48a ("caldav: make malformed calendar data
non-fatal in client"), but for the CardDAV side.
2026-11-13 14:58:01 +01:00
Robin van der Vleuten
2c2af7cdf2 caldav: add Calendar.Color
Read the calendar-color property in the http://apple.com/ns/ical/
namespace in FindCalendar and FindCalendars, and report it in PROPFIND
responses when it is set, the same way as calendar-description.
2026-11-13 14:29:23 +01:00
Robin van der Vleuten
ad1766c2ef
caldav, carddav: fill ReadOnly from current-user-privilege-set in client 2026-11-13 13:54:26 +01:00
Robin van der Vleuten
8ddea980d4 caldav: make malformed calendar data non-fatal in client
QueryCalendar and MultiGetCalendar returned no objects at all when the
calendar-data of one of them failed to parse. Skip that object instead
and report its error, with its href, in the returned error, like
multistatus errors since 71ae569.
2026-11-12 22:07:44 +01:00
Henry Stern
4ce863ae71 caldav, carddav: support If-Match/If-None-Match on client PUT
PutCalendarObject and PutAddressObject sent no conditional request
headers, so a client could not perform an optimistic-concurrency write
(overwrite only if the resource still carries an expected ETag). Add an
options parameter to both, reusing the existing server-side
PutCalendarObjectOptions / PutAddressObjectOptions types so the client
and Backend interface mirror each other. A nil opts preserves the prior
unconditional behaviour; a non-nil opts sets If-Match / If-None-Match.

Signed-off-by: Henry Stern <henry@stern.ca>
Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
Closes: https://github.com/emersion/go-webdav/issues/130
2026-11-12 17:55:00 +01:00
Robin van der Vleuten
bcd0dee048 webdav: add support for If-Match/If-None-Match in Client.RemoveAll
Client.RemoveAll had no way to send conditional headers, so a client
could not delete a resource only if it still has a known ETag. Take a
*RemoveAllOptions, the same type FileSystem.RemoveAll uses on the server
side. A nil value keeps the previous unconditional behavior.
2026-11-12 14:04:11 +01:00
Henry Stern
c16f8a9a13 caldav: decode inline calendar-data in SyncCollection responses
SyncCollection already requests calendar-data via the query's CompRequest, but
only the ETag and last-modified props were decoded, so a caller had to follow
every sync with a multiget even when the server (e.g. Radicale, SOGo) returned
the calendar object inline in the sync-collection response.

Decode the calendar-data prop into CalendarObject.Data when it is present; when
the server omits it, Data is left nil and the caller fetches it with a multiget
as before. Backward compatible.

Signed-off-by: Henry Stern <henry@stern.ca>
Assisted-by: Claude (Anthropic) <noreply@anthropic.com>
2026-06-28 12:28:23 +02:00
Anton Skorochod
1901d193ce caldav, carddav: derive current-user-privilege-set from a read-only flag
The server hard-coded DAV:read + DAV:write in current-user-privilege-set for
every collection (with a TODO). Add a ReadOnly field to Calendar and AddressBook
that the backend sets per request; report DAV:write only when it is false, so
clients (e.g. DAVx5, Apple) correctly mark read-only collections. Default
(false) keeps the previous read-write behavior.
2026-06-25 10:34:50 +02:00
Ruben Aleman
0463911636
internal: preserve trailing slashes in baseURL and principal path
Closes: https://github.com/emersion/go-webdav/issues/203
2026-04-11 12:38:55 +02:00
Gabor Pihaj
1916c2d907 caldav: get calendar data using PROPFIND
This change adds FindCalendar function to the caldav client. It can be
used to get calendar information without loading all the events, once the
path of the calendar is known.
2025-12-21 13:14:06 +01:00
Gabor Pihaj
8888fdf9b0
caldav: don't generate comp tag if it's empty
Closes: https://github.com/emersion/go-webdav/issues/196
2025-12-18 14:42:06 +01:00
LQR471814
82bb8a7aea caldav: add sync-collection functionality 2025-12-18 14:37:52 +01:00
Simon Ser
ca45607edf Upgrade dependencies 2025-12-18 14:34:29 +01:00
Simon Ser
9f9be606d3 internal: introduce HrefError
Holds the href value alongside the error.

References: https://github.com/emersion/go-webdav/issues/195
2025-11-16 18:41:10 +01:00
Simon Ser
71ae569e8a caldav: make multistatus errors non-fatal in client 2025-10-30 20:30:38 +01:00
Simon Ser
7083546bb3 carddav: make multistatus errors non-fatal in client 2025-10-30 20:30:26 +01:00
Simon Ser
5d86102d26 webdav: make multistatus errors non-fatal in client 2025-10-30 20:27:29 +01:00
Simon Ser
f93b8288cc webdav: use internal.PropFindValue in servePrincipalPropfind 2025-10-18 10:55:23 +02:00
prasad83
a16253aa97 caldav, carddav: add current-user-privilege-set 2025-10-18 10:48:59 +02:00
prasad83
0e74e6df11 caldav, carddav: add principal to resourcetype 2025-10-18 10:48:16 +02:00
Noah Kleiner
80149e46a4
internal/server: handle "allprop" with empty request and XML content type
The previous code failed to properly handle PROPFIND with an empty request body
(RFC 4918 section 9.1) for XML content type requests.

Refactor the logic to always consider PROPFIND requests with empty request
bodies as "allprop" requests, regardless of content type.

There is no need to worry about the request's content type if the request body
is empty anyway, so only parse if we know it is not.
2025-10-03 22:18:30 +02:00
Krystian Chachuła
e4babc2798 webdav: handle permission errors in ReadDir 2025-08-28 18:25:37 +02:00
Krystian Chachuła
87062437b6 webdav: return multistatus with 403 on PROPPATCH
This fixes a "The file cannot be accessed by the system" error when uploading
some files with Windows Explorer.
2025-07-09 01:28:14 +02:00
Jonathan Liu
75c185517e caldav: add expand request to client 2025-03-16 15:41:33 +01:00
krystiancha
b689d5daff
webdav: remove path from LocalFileSystem path errors
We don't want to show local paths in error messages.

`os.Is*` calls were replaced with `errors.Is` to also match the new
wrapped error.
2025-03-05 08:48:59 +01:00
Timo Furrer
002c347f47
caldav: support prop-filter in client requests
This change set adds support for correctly encoding the prop filters
into calendar requests.

Example Request with this change set:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<calendar-query
	xmlns="urn:ietf:params:xml:ns:caldav">
	<prop
		xmlns="DAV:">
		<calendar-data
			xmlns="urn:ietf:params:xml:ns:caldav">
			<comp
				xmlns="urn:ietf:params:xml:ns:caldav" name="VCALENDAR">
				<comp
					xmlns="urn:ietf:params:xml:ns:caldav" name="VEVENT">
					<prop
						xmlns="urn:ietf:params:xml:ns:caldav" name="UID">
					</prop>
					<prop
						xmlns="urn:ietf:params:xml:ns:caldav" name="ATTENDEE">
					</prop>
				</comp>
			</comp>
		</calendar-data>
		<getlastmodified
			xmlns="DAV:">
		</getlastmodified>
		<getetag
			xmlns="DAV:">
		</getetag>
	</prop>
	<filter
		xmlns="urn:ietf:params:xml:ns:caldav">
		<comp-filter
			xmlns="urn:ietf:params:xml:ns:caldav" name="VCALENDAR">
			<comp-filter
				xmlns="urn:ietf:params:xml:ns:caldav" name="VEVENT">
				<prop-filter
					xmlns="urn:ietf:params:xml:ns:caldav" name="UID">
					<text-match
						xmlns="urn:ietf:params:xml:ns:caldav">5bf5ee84-a9cf-4319-9def-437b00e2be8d
					</text-match>
				</prop-filter>
			</comp-filter>
		</comp-filter>
	</filter>
</calendar-query
```
2025-02-21 14:22:01 +01:00
Simon Ser
1b10baf554 ci: check gofmt, split build into separate task, enable -race 2025-02-21 10:52:48 +01:00
Timo Furrer
aba953c3b6 Implement context path discovery for CalDav/CardDav endpoint
This change set implements the "context path" discovery for the
CalDav/CardDav endpoints.

This basically implements the bootstrapping process as defined in
RFC6764 section 6, point 2 and 3.

What's missing in this implementation is the fallback that is described
in point 3, subpoint 3, which says that if the context path discovered
in the TXT RR is not reachable the .well-known URI should be used
instead.

I propose to implement this in a future iteration.
2025-02-21 10:50:48 +01:00
Timo Furrer
172968d292 Fix service name for CalDav/CardDav endpoint discovery
This change set fixes the service names used by the endpoint discovery
for CalDav and CardDav.
2025-02-21 10:50:48 +01:00
Simon Ser
0ae1d1be40 webdav: return 405 when directory already exists for MKCOL 2025-02-18 01:17:34 +01:00
Simon Ser
963b23b8d0 webdav: add support for If-Match/If-None-Match in DELETE 2025-02-14 18:26:04 +01:00
Simon Ser
c1bcf21ad4 webdav: fix ConditionalMatch.MatchETag when resource doesn't exist
Fixes "If-None-Match: *".
2025-02-14 16:49:26 +01:00
Simon Ser
3cc7466ac9 internal: add PropFindValue
NewPropFindResponse uses callbacks to lazily build the response.
However, some props are static: they don't require any processing
to generate. Add a small helper to reduce boilerplate a bit.
2025-01-13 23:00:32 +01:00
Simon Ser
9d778f4072 webdav: add support for If-Match/If-None-Match in FileSystem.Create 2024-12-09 22:31:59 +01:00
Simon Ser
93fee5bcf0 webdav: don't leave a partially uploaded file behind on error 2024-12-09 09:19:16 +01:00
Simon Ser
7f8c17ad71 readme: drop CI badge
The GitHub UI already displays that information.
2024-07-13 15:55:26 +02:00
Thomas Müller
810c51fa2d webdav: PUT response has no body and therefore should not have a content length header 2024-06-06 16:53:57 +02:00
Conrad Hoffmann
21f251fa1d Update go-ical
It's only a dependency update in go-ical, but it allows gettin rid of
rrule-go v.1.7, which is nice.
2024-04-19 16:39:09 +02:00
Thomas Müller
ff8598015d webdav: respond PUT request with 204/No Content in case the file already existed before putting 2024-04-17 15:51:26 +02:00
Thomas Müller
ffd81465fd webdav: FileSystem.Create() returns FileInfo and is used to set PUT response headers 2024-04-17 15:16:35 +02:00
Thomas Müller
948f33c2fc internal: use application/xml instead of text/xml which is deprecated 2024-04-11 17:16:25 +02:00
Thomas Müller
381b8a3cee carddav: add unit test for CardDAV mkcol 2024-04-09 12:55:19 +02:00
Thomas Müller
df447dc627 webdav: change FileSystem.Create to give implementations more control 2024-04-09 12:46:16 +02:00
Thomas Müller
3ed9a4f052 carddav, caldav: add missing headers on PUT
ETag and Last-Modified should be set to the new calendar object or
address object properties.
2024-03-28 11:22:46 +01:00
Conrad Hoffmann
25f1014ef2 internal: no status element in propstat responses
Responses that contain propstat elements do not contain their own
top-level status element, only the status elements inside the propstat
element.

See https://datatracker.ietf.org/doc/html/rfc4918#section-14.24 or any
of the examples for PROPFIND/PROPPATCH, starting e.g. here:
https://datatracker.ietf.org/doc/html/rfc4918#section-9.1.3
2024-02-08 23:12:59 +01:00
Conrad Hoffmann
ad1fe1c5a8
caldav, carddav: displayname and desription are optional
Both the displayname and the description can be absent for both
calendars and address books. If this is the case they should not show up
in PROPFIND responses as empty string.
2024-02-08 17:15:04 +01:00
Thomas Müller
0ea114ec79
caldav: add MKCOL support 2024-02-08 17:08:41 +01:00
Simon Ser
20fad80dff carddav: return HTTP 501 error instead of panicing 2024-02-07 17:26:50 +01:00
Dan Berglund
12d8b4bf62
caldav: return proper HTTP 501 instead of panicing
It seems like e.g. Apples reminders likes to send `PropPatch`, and
currently this just fills up my logs because of the panic. I thought it
would be better to signal that this isn't supported yet, which should
hopefully make it easier to dig through the logs.
2024-02-07 17:25:57 +01:00