Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure /app/new takes target as absolute path #2305

Merged
merged 2 commits into from
Nov 26, 2021
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/app-abspath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Make sure /app/new takes `target` as absolute path

A mini-PR to make the `target` parameter absolute (by prepending `/` if missing).

https://github.com/cs3org/reva/pull/2305
7 changes: 7 additions & 0 deletions internal/http/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
return
}

// TODO(lopresti) if target is relative, currently the gateway fails to identify a storage provider (?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do support relative references but I don’t know if web can work with those

For now, it’s good enough

// and just returns a CODE_INTERNAL error on InitiateFileUpload.
// Therefore for now make sure the target is absolute.
if target[0] != '/' {
target = "/" + target
}

// Create empty file via storageprovider
createReq := &provider.InitiateFileUploadRequest{
Ref: &provider.Reference{Path: target},
Expand Down
7 changes: 4 additions & 3 deletions internal/http/services/ocmd/reqres.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ type APIError struct {
}

// WriteError handles writing error responses
func WriteError(w http.ResponseWriter, r *http.Request, code APIErrorCode, message string, err error) {
if err != nil {
appctx.GetLogger(r.Context()).Error().Err(err).Msg(message)
func WriteError(w http.ResponseWriter, r *http.Request, code APIErrorCode, message string, e error) {
if e != nil {
appctx.GetLogger(r.Context()).Error().Err(e).Msg(message)
}

var encoded []byte
var err error
w.Header().Set("Content-Type", "application/json")
encoded, err = json.MarshalIndent(APIError{Code: code, Message: message}, "", " ")

Expand Down