all: encode hrefs, replace hrefs with path in public API

Closes: https://github.com/emersion/go-webdav/issues/14
Closes: https://github.com/emersion/go-webdav/issues/16
This commit is contained in:
Simon Ser
2020-01-22 11:07:30 +01:00
parent 72c96af206
commit 6eeeccb96e
11 changed files with 96 additions and 92 deletions

View File

@@ -99,7 +99,7 @@ func (h *Handler) handleQuery(w http.ResponseWriter, query *addressbookQuery) er
func (h *Handler) handleMultiget(w http.ResponseWriter, multiget *addressbookMultiget) error {
var resps []internal.Response
for _, href := range multiget.Hrefs {
ao, err := h.Backend.GetAddressObject(href)
ao, err := h.Backend.GetAddressObject(href.Path)
if err != nil {
return err // TODO: create internal.Response with error
}
@@ -225,11 +225,11 @@ func (b *backend) propfindAddressBook(propfind *internal.Propfind, ab *AddressBo
},
// TODO: this is a principal property
addressBookHomeSetName: func(*internal.RawXMLValue) (interface{}, error) {
return &addressbookHomeSet{Href: "/"}, nil
return &addressbookHomeSet{Href: internal.Href{Path: "/"}}, nil
},
// TODO: this should be set on all resources
internal.CurrentUserPrincipalName: func(*internal.RawXMLValue) (interface{}, error) {
return &internal.CurrentUserPrincipal{Href: "/"}, nil
return &internal.CurrentUserPrincipal{Href: internal.Href{Path: "/"}}, nil
},
}
@@ -258,7 +258,7 @@ func (b *backend) propfindAddressObject(propfind *internal.Propfind, ao *Address
// TODO: getlastmodified, getetag
}
return internal.NewPropfindResponse(ao.Href, propfind, props)
return internal.NewPropfindResponse(ao.Path, propfind, props)
}
func (b *backend) Proppatch(r *http.Request, update *internal.Propertyupdate) (*internal.Response, error) {