matcha
matcha copied to clipboard
BUG: Improve bodyCacheFile filename sanitization
Describe the bug
The bodyCacheFile function in config/cache.go replaces some characters with _ but might miss others that are invalid in filenames on certain operating systems (e.g. *, ?, \", <, >, |).
To reproduce
- Create a mailbox folder with a character like
*(if the server allows it). - Attempt to view an email in that folder.
- Cache file creation might fail on Windows or other strict filesystems.
Expected behavior
Robust sanitization of folder names for use in filenames.
Additional context
func bodyCacheFile(folderName string) (string, error) {
dir, err := bodyCacheDir()
if err != nil {
return "", err
}
safe := strings.NewReplacer("/", "_", "\\", "_", ":", "_", " ", "_").Replace(folderName)
return filepath.Join(dir, safe+".json"), nil
}
This has had no activity for 30 days. It will be closed in 14 days unless updated. Comment or remove the stale label to keep it open.
Closing due to inactivity. Reopen if still relevant.