Skip to content

Commit

Permalink
Merge pull request #10738 from owncloud/webdav_format_lastmodified
Browse files Browse the repository at this point in the history
fix: change the format to RFC1123 to follow the specs
  • Loading branch information
kobergj authored Dec 10, 2024
2 parents 8006b5d + 2e3f21a commit 4df9532
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/webdav-report-date-format.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: GetLastModified property in the REPORT response will use RFC1123 format

This will follow the standard and will also match the format of the same property in the PROPFIND response

https://github.com/owncloud/ocis/pull/10738
5 changes: 5 additions & 0 deletions services/webdav/pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ type contextKey int
const (
ContextKeyID contextKey = iota
ContextKeyPath

// RFC1123 time that mimics oc10. time.RFC1123 would end in "UTC", see https://github.com/golang/go/issues/13781
// Format copied from internal package https://github.com/cs3org/reva/blob/edge/internal/http/services/owncloud/ocdav/net/net.go.
// It's needed to match the times shown in PROPFIND and REPORT requests.
RFC1123 = "Mon, 02 Jan 2006 15:04:05 GMT"
)
4 changes: 2 additions & 2 deletions services/webdav/pkg/service/v0/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"path"
"strconv"
"strings"
"time"

provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
merrors "go-micro.dev/v4/errors"
Expand All @@ -21,6 +20,7 @@ import (
"github.com/cs3org/reva/v2/pkg/utils"
searchmsg "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/search/v0"
searchsvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/search/v0"
"github.com/owncloud/ocis/v2/services/webdav/pkg/constants"
"github.com/owncloud/ocis/v2/services/webdav/pkg/net"
"github.com/owncloud/ocis/v2/services/webdav/pkg/prop"
"github.com/owncloud/ocis/v2/services/webdav/pkg/propfind"
Expand Down Expand Up @@ -192,7 +192,7 @@ func matchToPropResponse(ctx context.Context, match *searchmsg.Match) (*propfind
})))
}
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:name", match.Entity.Name))
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("d:getlastmodified", match.Entity.LastModifiedTime.AsTime().Format(time.RFC3339)))
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("d:getlastmodified", match.Entity.LastModifiedTime.AsTime().Format(constants.RFC1123)))
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("d:getcontenttype", match.Entity.MimeType))
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:permissions", match.Entity.Permissions))
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:highlights", match.Entity.Highlights))
Expand Down

0 comments on commit 4df9532

Please sign in to comment.