wings
wings copied to clipboard
Fix file path handling in download router
This pull request improves how file downloads are handled in the getDownloadFile function, focusing on safer and more accurate processing of file paths and filenames. The main changes include decoding URL-encoded file paths, extracting the correct filename for the download header, and updating imports to support these changes.
File path handling and download improvements:
- Decoded the URL-encoded file path from the download token using
url.QueryUnescapeto ensure correct file access and prevent issues with encoded characters. - Updated the call to
s.Filesystem().Fileto use the decodedfilePathinstead of the original token value, ensuring the correct file is accessed. - Used
filepath.Baseto extract the filename from the full file path for theContent-Dispositionheader, ensuring the downloaded file has the correct name regardless of the original path.
Dependency updates:
- Added imports for
net/urlandpath/filepathto support URL decoding and filename extraction.
🔗 Linked Issues: #5256