about summary refs log tree commit diff stats
path: root/commands/msgview/save.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/msgview/save.go')
-rw-r--r--commands/msgview/save.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index ef6bba8..5d01e4d 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -182,9 +182,17 @@ func generateFilename(part *models.BodyStructure) string {
 		filename = fn
 	} else if fn, ok := part.Params["name"]; ok {
 		filename = fn
-	} else {
+	}
+	// Some MUAs send attachments with names like /some/stupid/idea/happy.jpeg
+	// Assuming non hostile intent it does make sense to use just the last
+	// portion of the pathname as the filename for saving it.
+	filename = filename[strings.LastIndex(filename, "/")+1:]
+	switch filename {
+	case "", ".", "..":
 		timestamp := time.Now().Format("2006-01-02-150405")
 		filename = fmt.Sprintf("aerc_%v", timestamp)
+	default:
+		// already have a valid name
 	}
 	return filename
 }
' href='#n114'>114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177