Ensure folderPath ends with / for proper relative path calculation in ZIP downloads

This commit is contained in:
Leon Bösche
2026-01-14 12:11:25 +01:00
parent de720cbdcb
commit 40f7eeee09
2 changed files with 10 additions and 6 deletions

Binary file not shown.

View File

@@ -1881,13 +1881,15 @@ func downloadOrgFolderAsZip(w http.ResponseWriter, r *http.Request, db *database
zipWriter := zip.NewWriter(w)
defer zipWriter.Close()
// Ensure folderPath ends with / for proper relative path calculation
if !strings.HasSuffix(folderPath, "/") {
folderPath += "/"
}
// Add each file to ZIP
for _, file := range fileList {
// Calculate relative path in ZIP
relPath := strings.TrimPrefix(file.Path, folderPath)
if relPath[0] == '/' {
relPath = relPath[1:]
}
// Download file from WebDAV
remoteRel := strings.TrimPrefix(file.Path, "/")
@@ -2035,13 +2037,15 @@ func downloadUserFolderAsZip(w http.ResponseWriter, r *http.Request, db *databas
zipWriter := zip.NewWriter(w)
defer zipWriter.Close()
// Ensure folderPath ends with / for proper relative path calculation
if !strings.HasSuffix(folderPath, "/") {
folderPath += "/"
}
// Add each file to ZIP
for _, file := range fileList {
// Calculate relative path in ZIP
relPath := strings.TrimPrefix(file.Path, folderPath)
if relPath[0] == '/' {
relPath = relPath[1:]
}
// Download file from WebDAV
remotePath := strings.TrimPrefix(file.Path, "/")