[PATCH] Only save the last part of an attachment of which the name is a filepath
Export this patch
---
commands/msgview/save.go | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index ef6bba8..7649a5f 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -181,8 +181,11 @@ func generateFilename(part *models.BodyStructure) string {
if fn, ok := part.DispositionParams["filename"]; ok {
filename = fn
} else if fn, ok := part.Params["name"]; ok {
- filename = fn
- } else {
+ filename = fn
+ }
+ // Used to handle "/", "." and ".." in filenames correctly
+ filename = filename[strings.LastIndex(filename, "/")+1:]
+ if filename == "" || filename == "." || filename == ".." {
timestamp := time.Now().Format("2006-01-02-150405")
filename = fmt.Sprintf("aerc_%v", timestamp)
}
--
2.29.2