Skip to content

Fix file path handling in download router#299

Open
KroZen-Dev wants to merge 1 commit intopterodactyl:developfrom
KroZen-Dev:fix/url-encoded-file-downloads
Open

Fix file path handling in download router#299
KroZen-Dev wants to merge 1 commit intopterodactyl:developfrom
KroZen-Dev:fix/url-encoded-file-downloads

Conversation

@KroZen-Dev
Copy link

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.QueryUnescape to ensure correct file access and prevent issues with encoded characters.
  • Updated the call to s.Filesystem().File to use the decoded filePath instead of the original token value, ensuring the correct file is accessed.
  • Used filepath.Base to extract the filename from the full file path for the Content-Disposition header, ensuring the downloaded file has the correct name regardless of the original path.

Dependency updates:

  • Added imports for net/url and path/filepath to support URL decoding and filename extraction.

🔗 Linked Issues: #5256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant