mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-23 00:34:23 +00:00
webdav: remove DAV: prefix hack
This commit is contained in:
parent
fd5d1f32d2
commit
2807ec1dd2
@ -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
29
xml.go
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user