webdav: remove DAV: prefix hack

This commit is contained in:
emersion 2017-09-10 12:35:04 +02:00
parent fd5d1f32d2
commit 2807ec1dd2
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 1 additions and 30 deletions

View File

@ -245,7 +245,7 @@ func TestEscapeXML(t *testing.T) {
func TestFilenameEscape(t *testing.T) { func TestFilenameEscape(t *testing.T) {
hrefRe := regexp.MustCompile(`<href xmlns="DAV:">([^<]*)</href>`) hrefRe := regexp.MustCompile(`<href xmlns="DAV:">([^<]*)</href>`)
displayNameRe := regexp.MustCompile(`<D:displayname>([^<]*)</D:displayname>`) displayNameRe := regexp.MustCompile(`<displayname xmlns="DAV:">([^<]*)</displayname>`)
do := func(method, urlStr string) (string, string, error) { do := func(method, urlStr string) (string, string, error) {
req, err := http.NewRequest(method, urlStr, nil) req, err := http.NewRequest(method, urlStr, nil)
if err != nil { if err != nil {

29
xml.go
View File

@ -221,35 +221,6 @@ type propstat struct {
ResponseDescription string `xml:"DAV: responsedescription,omitempty"` ResponseDescription string `xml:"DAV: responsedescription,omitempty"`
} }
// MarshalXML prepends the "D:" namespace prefix on properties in the DAV: namespace
// before encoding. See multistatusWriter.
func (ps propstat) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
// Convert from a propstat to an propstat.
xmlPs := propstat{
Prop: make([]Property, len(ps.Prop)),
Status: ps.Status,
Error: ps.Error,
ResponseDescription: ps.ResponseDescription,
}
for k, prop := range ps.Prop {
xmlPs.Prop[k] = Property{
XMLName: xml.Name(prop.XMLName),
Lang: prop.Lang,
InnerXML: prop.InnerXML,
}
}
for k, prop := range xmlPs.Prop {
if prop.XMLName.Space == "DAV:" {
prop.XMLName = xml.Name{Space: "", Local: "D:" + prop.XMLName.Local}
xmlPs.Prop[k] = prop
}
}
// Distinct type to avoid infinite recursion of MarshalXML.
type newpropstat propstat
return e.EncodeElement(newpropstat(xmlPs), start)
}
// http://www.webdav.org/specs/rfc4918.html#ELEMENT_response // http://www.webdav.org/specs/rfc4918.html#ELEMENT_response
// See multistatusWriter for the "D:" namespace prefix. // See multistatusWriter for the "D:" namespace prefix.
type response struct { type response struct {