matcha icon indicating copy to clipboard operation
matcha copied to clipboard

BUG: Improve bodyCacheFile filename sanitization

Open andrinoff opened this issue 7 months ago • 2 comments

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

  1. Create a mailbox folder with a character like * (if the server allows it).
  2. Attempt to view an email in that folder.
  3. 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
}

andrinoff avatar Apr 16 '26 13:04 andrinoff

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.

floatpanebot avatar May 17 '26 05:05 floatpanebot

Closing due to inactivity. Reopen if still relevant.

floatpanebot avatar May 31 '26 06:05 floatpanebot