Escape file name for content-disposition.

This commit is contained in:
Matthew Kilgore
2025-06-30 20:55:11 -04:00
parent 1fd2f42282
commit 04c8e38ecf

View File

@@ -3,6 +3,7 @@ package v1
import (
"errors"
"net/http"
"net/url"
"path/filepath"
"strconv"
"strings"
@@ -203,7 +204,9 @@ func (ctrl *V1Controller) handleItemAttachmentsHandler(w http.ResponseWriter, r
}
}(bucket)
w.Header().Set("Content-Disposition", "attachment; filename="+doc.Title)
// Set the Content-Disposition header for RFC6266 compliance
disposition := "attachment; filename*=UTF-8''" + url.QueryEscape(doc.Title)
w.Header().Set("Content-Disposition", disposition)
http.ServeContent(w, r, doc.Title, doc.CreatedAt, file)
return nil