]> git.r.bdr.sh - rbdr/mobius/commitdiff
Allow home uploads
authorRuben Beltran del Rio <redacted>
Mon, 3 Feb 2025 22:18:39 +0000 (23:18 +0100)
committerRuben Beltran del Rio <redacted>
Mon, 3 Feb 2025 22:18:39 +0000 (23:18 +0100)
hotline/file_path.go
internal/mobius/transaction_handlers.go

index f4a27cc587b9c89f876ba7593adac1323573c350..bb6bbd312b62864591b893774930d23da5b19227 100644 (file)
@@ -98,6 +98,15 @@ func (fp *FilePath) IsUploadDir() bool {
        return strings.Contains(strings.ToLower(string(fp.Items[fp.Len()-1].Name)), "upload")
 }
 
+func (fp *FilePath) IsUserDir() bool {
+    if fp.Len() == 0 {
+        return false
+    }
+
+    return strings.HasPrefix(string(fp.Items[0].Name), "~")
+}
+
+
 func (fp *FilePath) Len() uint16 {
        return binary.BigEndian.Uint16(fp.ItemCount[:])
 }
index 0cba65afc204d82d8c9529a6d26325d0211f2c42..e74056f8dc4da49eda764c33b1ff9356692b005e 100644 (file)
@@ -1385,7 +1385,7 @@ func HandleUploadFolder(cc *hotline.ClientConn, t *hotline.Transaction) (res []h
 
        // Handle special cases for Upload and Drop Box folders
        if !cc.Authorize(hotline.AccessUploadAnywhere) {
-               if !fp.IsUploadDir() && !fp.IsDropbox() {
+               if !fp.IsUploadDir() && !fp.IsDropbox() && !fp.IsUserDir() {
                        return cc.NewErrReply(t, fmt.Sprintf("Cannot accept upload of the folder \"%v\" because you are only allowed to upload to the \"Uploads\" folder.", string(t.GetField(hotline.FieldFileName).Data)))
                }
        }
@@ -1428,7 +1428,7 @@ func HandleUploadFile(cc *hotline.ClientConn, t *hotline.Transaction) (res []hot
 
        // Handle special cases for Upload and Drop Box folders
        if !cc.Authorize(hotline.AccessUploadAnywhere) {
-               if !fp.IsUploadDir() && !fp.IsDropbox() {
+               if !fp.IsUploadDir() && !fp.IsDropbox() && !fp.IsUserDir() {
                        return cc.NewErrReply(t, fmt.Sprintf("Cannot accept upload of the file \"%v\" because you are only allowed to upload to the \"Uploads\" folder.", string(fileName)))
                }
        }