Skip to content

fix(telegram): sanitize download filenames - #5

Merged
fdciabdul merged 1 commit into
imtaqin:mainfrom
I3eka:fix/windows-download-filenames
Aug 4, 2026
Merged

fix(telegram): sanitize download filenames#5
fdciabdul merged 1 commit into
imtaqin:mainfrom
I3eka:fix/windows-download-filenames

Conversation

@I3eka

@I3eka I3eka commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • sanitize both registry keys and Telegram-provided names before creating local download paths
  • replace Windows-invalid and control characters, and trim trailing dots or spaces
  • add regression coverage for photo keys and unsafe document names

Testing

  • go test ./...

Copilot AI lite review requested due to automatic review settings August 4, 2026 09:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Ready to approve

The sanitization logic is applied at the right boundary (path construction), and the added unit tests cover the intended regression scenarios without introducing behavioral risks elsewhere.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR hardens the local download-path generation in internal/telegram by sanitizing both the internal registry key and Telegram-provided filenames, aiming to prevent invalid/unsafe filenames (notably on Windows) and to avoid path-related surprises.

Changes:

  • Sanitize both halves of the generated download filename (registry key + Telegram filename) before joining into the storage directory path.
  • Add sanitizeDownloadFileName helper to replace Windows-invalid/control characters and trim trailing dots/spaces.
  • Add a small regression test suite covering photo keys and unsafe document names.
File summaries
File Description
internal/telegram/files.go Applies centralized filename sanitization when generating the download target path; adds the sanitization helper.
internal/telegram/files_test.go Adds regression tests to ensure expected sanitization behavior for common/unsafe inputs.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@fdciabdul
fdciabdul merged commit 627d354 into imtaqin:main Aug 4, 2026
7 checks passed
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.

3 participants