Try to compare the diff of encoding/xml.
This commit is contained in:
parent
0879eb2f95
commit
b076a43f30
@ -1,50 +0,0 @@
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package dav
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
// SlashClean is equivalent to but slightly more efficient than
|
||||
// path.Clean("/" + name).
|
||||
func SlashClean(name string) string {
|
||||
if name == "" || name[0] != '/' {
|
||||
name = "/" + name
|
||||
}
|
||||
return path.Clean(name)
|
||||
}
|
||||
|
||||
// A FileSystem implements access to a collection of named files. The elements
|
||||
// in a file path are separated by slash ('/', U+002F) characters, regardless
|
||||
// of host operating system convention.
|
||||
//
|
||||
// Each method has the same semantics as the os package's function of the same
|
||||
// name.
|
||||
//
|
||||
// Note that the os.Rename documentation says that "OS-specific restrictions
|
||||
// might apply". In particular, whether or not renaming a file or directory
|
||||
// overwriting another existing file or directory is an error is OS-dependent.
|
||||
type FileSystem interface {
|
||||
Mkdir(ctx context.Context, name string, perm os.FileMode) error
|
||||
OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (File, error)
|
||||
RemoveAll(ctx context.Context, name string) error
|
||||
Rename(ctx context.Context, oldName, newName string) error
|
||||
Stat(ctx context.Context, name string) (os.FileInfo, error)
|
||||
}
|
||||
|
||||
// A File is returned by a FileSystem's OpenFile method and can be served by a
|
||||
// Handler.
|
||||
//
|
||||
// A File may optionally implement the DeadPropsHolder interface, if it can
|
||||
// load and save dead properties.
|
||||
type File interface {
|
||||
http.File
|
||||
io.Writer
|
||||
}
|
@ -4,6 +4,7 @@ import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
"strconv"
|
||||
"tank/rest/dav"
|
||||
)
|
||||
@ -17,6 +18,17 @@ type LiveProp struct {
|
||||
dir bool
|
||||
}
|
||||
|
||||
|
||||
// SlashClean is equivalent to but slightly more efficient than
|
||||
// path.Clean("/" + name).
|
||||
func SlashClean(name string) string {
|
||||
if name == "" || name[0] != '/' {
|
||||
name = "/" + name
|
||||
}
|
||||
return path.Clean(name)
|
||||
}
|
||||
|
||||
|
||||
//所有的动态属性定义及其值的获取方式
|
||||
var LivePropMap = map[xml.Name]LiveProp{
|
||||
{Space: "DAV:", Local: "resourcetype"}: {
|
||||
@ -31,7 +43,7 @@ var LivePropMap = map[xml.Name]LiveProp{
|
||||
},
|
||||
{Space: "DAV:", Local: "displayname"}: {
|
||||
findFn: func(user *User, matter *Matter) string {
|
||||
if dav.SlashClean(matter.Name) == "/" {
|
||||
if SlashClean(matter.Name) == "/" {
|
||||
return ""
|
||||
} else {
|
||||
return dav.EscapeXML(matter.Name)
|
||||
|
Loading…
Reference in New Issue
Block a user