]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/transaction_handlers.go
Fix more filepaths
[rbdr/mobius] / hotline / transaction_handlers.go
index c3b8c592bf2f5d8ea55a533ce5c6251544d9175e..cf55c07afa7d041bf4101be5872e728ed56744c3 100644 (file)
@@ -10,6 +10,7 @@ import (
        "math/big"
        "os"
        "path"
+       "path/filepath"
        "sort"
        "strings"
        "time"
@@ -558,11 +559,12 @@ func HandleNewFolder(cc *ClientConn, t *Transaction) (res []Transaction, err err
                res = append(res, cc.NewErrReply(t, "You are not allowed to create folders."))
                return res, err
        }
-       newFolderPath := cc.Server.Config.FileRoot
        folderName := string(t.GetField(fieldFileName).Data)
 
        folderName = path.Join("/", folderName)
 
+       var subPath string
+
        // fieldFilePath is only present for nested paths
        if t.GetField(fieldFilePath).Data != nil {
                var newFp FilePath
@@ -570,9 +572,12 @@ func HandleNewFolder(cc *ClientConn, t *Transaction) (res []Transaction, err err
                if err != nil {
                        return nil, err
                }
-               newFolderPath += newFp.String()
+
+               for _, pathItem := range newFp.Items {
+                       subPath = filepath.Join("/", subPath, string(pathItem.Name))
+               }
        }
-       newFolderPath = path.Join(newFolderPath, folderName)
+       newFolderPath := path.Join(cc.Server.Config.FileRoot, subPath, folderName)
 
        // TODO: check path and folder name lengths
 
@@ -1667,7 +1672,7 @@ func HandleGetFileNameList(cc *ClientConn, t *Transaction) (res []Transaction, e
 
        // Handle special case for drop box folders
        if fp.IsDropbox() && !authorize(cc.Account.Access, accessViewDropBoxes) {
-               res = append(res, cc.NewReply(t))
+               res = append(res, cc.NewErrReply(t, "You are not allowed to view drop boxes."))
                return res, err
        }