Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-special-characters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Handle special characters in file names correctly

- Fixed PROPFIND response when listing a folder named with special charactrers

https://github.com/cs3org/reva/pull/5451
11 changes: 5 additions & 6 deletions internal/http/services/owncloud/ocdav/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ import (
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/v3/internal/grpc/services/storageprovider"
"github.com/cs3org/reva/v3/pkg/appctx"
"github.com/cs3org/reva/v3/pkg/spaces"
"github.com/cs3org/reva/v3/pkg/permissions"
"github.com/cs3org/reva/v3/pkg/spaces"

"github.com/pkg/errors"


"github.com/cs3org/reva/v3/pkg/publicshare"
"github.com/cs3org/reva/v3/pkg/share"
Expand Down Expand Up @@ -512,23 +511,23 @@ func (s *svc) mdToPropResponse(ctx context.Context, pf *propfindXML, md *provide

var href string
if parent != nil {
relativePath, err := filepath.Rel(parent.Path, md.Path)
relativePath, err := filepath.Rel(encodePath(parent.Path), encodePath(md.Path))
if err != nil {
return nil, errors.Wrapf(err, "failed to calculate path relative to parent: %v", md.Path)
}
href, err = url.JoinPath(hrefBase, relativePath)
href, err = url.JoinPath(encodePath(hrefBase), relativePath)
if err != nil {
return nil, errors.Wrapf(err, "failed to join relative path with ref: %v", md.Path)
}
} else {
// If no parent specified, we just take space id + path relative to space
spaceID := md.Id.SpaceId
spacePath, _ := spaces.DecodeSpaceID(spaceID)
relativePath, err := filepath.Rel(spacePath, md.Path)
relativePath, err := filepath.Rel(spacePath, encodePath(md.Path))
if err != nil {
return nil, errors.Wrapf(err, "failed to calculate path relative to space: %v. %v", spacePath, md.Path)
}
href, err = url.JoinPath(hrefBase, spaceID, relativePath)
href, err = url.JoinPath(encodePath(hrefBase), spaceID, relativePath)
if err != nil {
return nil, errors.Wrapf(err, "failed to join relative path with ref: %v", md.Path)
}
Expand Down
11 changes: 6 additions & 5 deletions pkg/eosclient/eosgrpc/eoshttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ type HTTPOptions struct {

// TTL for an idle conn per transport
IdleConnTimeout int

// If the URL is https, then we need to configure this client
// with the usual TLS stuff
// Defaults are /etc/grid-security/hostcert.pem and /etc/grid-security/hostkey.pem
Expand Down Expand Up @@ -229,9 +228,11 @@ func (c *EOSHTTPClient) buildFullURL(urlpath string, auth eosclient.Authorizatio
}
}

urlpathEncoded := strings.ReplaceAll(url.PathEscape(urlpath), "%2F", "/")

fullurl := strings.TrimRight(c.opt.BaseURL, "/")
fullurl += "/"
fullurl += strings.TrimLeft(urlpath, "/")
fullurl += strings.TrimLeft(urlpathEncoded, "/")

if pos < 0 {
fullurl += "?"
Expand All @@ -245,7 +246,7 @@ func (c *EOSHTTPClient) buildFullURL(urlpath string, auth eosclient.Authorizatio

u, err := url.Parse(fullurl)
if err != nil {
return "", errtypes.PermissionDenied("Could not parse url " + urlpath)
return "", errtypes.PermissionDenied("Could not parse url " + urlpathEncoded)
}

final := strings.ReplaceAll(u.String(), "#", "%23")
Expand Down Expand Up @@ -381,11 +382,11 @@ func (c *EOSHTTPClient) PUTFile(ctx context.Context, remoteuser string, auth eos
log.Info().Str("func", "PUTFile").Str("remoteuser", remoteuser).Str("uid,gid", auth.Role.UID+","+auth.Role.GID).Str("path", urlpath).Int64("length", length).Str("app", app).Msg("")

// Now send the req and see what happens
tempUrl, err := c.buildFullURL(urlpath, auth)
tempURL, err := c.buildFullURL(urlpath, auth)
if err != nil {
return err
}
base, err := url.Parse(tempUrl)
base, err := url.Parse(tempURL)
if err != nil {
return errtypes.PermissionDenied("Could not parse url " + urlpath)
}
Expand Down