emersion / go-webdav

A Go library for WebDAV, CalDAV and CardDAV
MIT License
314 stars 66 forks source link

fix: check etag quotes before unquote #129

Closed in0rdr closed 11 months ago

in0rdr commented 1 year ago

I encountered the same issue with non-standard (unquoted) etags from my caldav server as my predecessors:

go test
--- FAIL: TestETagUnmarshalText (0.00s)
    elements_test.go:79: UnmarshalText failed for ETag: webdav: failed to unquote ETag: invalid syntax
FAIL
exit status 1
FAIL    github.com/emersion/go-webdav/internal  0.006s

This patch will check the etag first, before calling the strconv.Unquote function. A string without quotes will not be unquoted.

emersion commented 1 year ago

This will not behave properly when encoding the value.