فهرست منبع

webdav: convert to UTC before using http.TimeFormat

http.TimeFormat hard-codes GMT and is documented that:

> TimeFormat is the time format to use when generating times in HTTP
> headers. It is like time.RFC1123 but hard-codes GMT as the time
> zone. The time being formatted must be in UTC for Format to generate
> the correct format.

These two users weren't UTC-ifying the time.Time first.

Fixes golang/go#25015

Change-Id: I82be01856260e363361137fd9651b1940f439f21
Reviewed-on: https://go-review.googlesource.com/113795
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Brad Fitzpatrick 7 سال پیش
والد
کامیت
57065200b4
2فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 1 1
      webdav/prop.go
  2. 1 1
      webdav/prop_test.go

+ 1 - 1
webdav/prop.go

@@ -376,7 +376,7 @@ func findContentLength(ctx context.Context, fs FileSystem, ls LockSystem, name s
 }
 
 func findLastModified(ctx context.Context, fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) {
-	return fi.ModTime().Format(http.TimeFormat), nil
+	return fi.ModTime().UTC().Format(http.TimeFormat), nil
 }
 
 func findContentType(ctx context.Context, fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) {

+ 1 - 1
webdav/prop_test.go

@@ -29,7 +29,7 @@ func TestMemPS(t *testing.T) {
 			for i, p := range pst.Props {
 				switch p.XMLName {
 				case xml.Name{Space: "DAV:", Local: "getlastmodified"}:
-					p.InnerXML = []byte(fi.ModTime().Format(http.TimeFormat))
+					p.InnerXML = []byte(fi.ModTime().UTC().Format(http.TimeFormat))
 					pst.Props[i] = p
 				case xml.Name{Space: "DAV:", Local: "getetag"}:
 					if fi.IsDir() {