From ff4dac0b3bfce9ed36f1ef3a9af1dd11da4db33a Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Sun, 27 Jun 2021 12:59:04 +0200 Subject: [PATCH 1/3] Add a proper XML header to error replies. See owncloud/product#273 for more details. --- internal/http/services/owncloud/ocdav/error.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/http/services/owncloud/ocdav/error.go b/internal/http/services/owncloud/ocdav/error.go index b8947481d8..4c0fbcb385 100644 --- a/internal/http/services/owncloud/ocdav/error.go +++ b/internal/http/services/owncloud/ocdav/error.go @@ -58,13 +58,17 @@ type exception struct { // Marshal just calls the xml marshaller for a given exception. func Marshal(e exception) ([]byte, error) { - return xml.Marshal(&errorXML{ + xmlstring, err := xml.Marshal(&errorXML{ Xmlnsd: "DAV", Xmlnss: "http://sabredav.org/ns", Exception: codesEnum[e.code], Message: e.message, Header: e.header, }) + if err == nil { + return []byte(xml.Header + string(xmlstring)), err + } + return []byte(""), err } // http://www.webdav.org/specs/rfc4918.html#ELEMENT_error From 90a5f3da16ad93a7cc72a44c81d952722dd4f5dc Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Mon, 28 Jun 2021 15:13:13 +0200 Subject: [PATCH 2/3] Add a changelog entry for the missing xml header --- changelog/unreleased/xmlheadertoerrors.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/unreleased/xmlheadertoerrors.md diff --git a/changelog/unreleased/xmlheadertoerrors.md b/changelog/unreleased/xmlheadertoerrors.md new file mode 100644 index 0000000000..16d0227e0b --- /dev/null +++ b/changelog/unreleased/xmlheadertoerrors.md @@ -0,0 +1,3 @@ +Bugfix: send a proper XML header with error messages + +https://github.com/cs3org/reva/pull/1828 From d0383080d2eba5d9e6c627381de89d0e2446e31e Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Mon, 28 Jun 2021 18:16:31 +0200 Subject: [PATCH 3/3] Reverse if statement to follow golang style --- internal/http/services/owncloud/ocdav/error.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/http/services/owncloud/ocdav/error.go b/internal/http/services/owncloud/ocdav/error.go index 4c0fbcb385..db1ada8446 100644 --- a/internal/http/services/owncloud/ocdav/error.go +++ b/internal/http/services/owncloud/ocdav/error.go @@ -65,10 +65,10 @@ func Marshal(e exception) ([]byte, error) { Message: e.message, Header: e.header, }) - if err == nil { - return []byte(xml.Header + string(xmlstring)), err + if err != nil { + return []byte(""), err } - return []byte(""), err + return []byte(xml.Header + string(xmlstring)), err } // http://www.webdav.org/specs/rfc4918.html#ELEMENT_error