diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-02-03 23:18:39 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-02-03 23:18:39 +0100 |
| commit | d34160c512a52cf1f5caf59fa00372d3a627e24c (patch) | |
| tree | 69dba9fe235cba656c8003e4415a696dc915ac5b | |
| parent | 7bd6f5adda126bbe7caf94330e08d9adf0e66466 (diff) | |
Allow home uploads
| -rw-r--r-- | hotline/file_path.go | 9 | ||||
| -rw-r--r-- | internal/mobius/transaction_handlers.go | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/hotline/file_path.go b/hotline/file_path.go index f4a27cc..bb6bbd3 100644 --- a/hotline/file_path.go +++ b/hotline/file_path.go @@ -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[:]) } diff --git a/internal/mobius/transaction_handlers.go b/internal/mobius/transaction_handlers.go index 0cba65a..e74056f 100644 --- a/internal/mobius/transaction_handlers.go +++ b/internal/mobius/transaction_handlers.go @@ -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))) } } |