aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msgview/save.go
diff options
context:
space:
mode:
authorLeszek CimaƂa <ernierasta@zori.cz>2019-12-07 19:58:12 +0100
committerDrew DeVault <sir@cmpwn.com>2019-12-07 14:30:35 -0500
commit4f2892695e1fdf89274bff434474b5d95e25ef5e (patch)
tree8941a3f9b10d3ea66f2326e840cb795161e91d96 /commands/msgview/save.go
parente84e402e489569b2ab1636ae04016464ec6d46c3 (diff)
downloadaerc-4f2892695e1fdf89274bff434474b5d95e25ef5e.tar.gz
failback to Content-Type filename when encoded Content-Disposition is used
Hi! This patch will fix missing filename if it is RFC2231 encoded with charset different then ASCII or UTF8. Example how it looks like in mail: Content-Type: application/pdf; name="=?UTF-8?Q?Opis_przedmiotu_zam=c3=b3wienia_-_za=c5=82=c4=85cznik_nr_1?= =?UTF-8?Q?=2epdf?=" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename*0*=iso-8859-2''%4F%70%69%73%20%70%72%7A%65%64%6D%69%6F%74%75%20; filename*1*=%7A%61%6D%F3%77%69%65%6E%69%61%20%2D%20%7A%61%B3%B1%63%7A%6E; filename*2*=%69%6B%20%6E%72%20%31%2E%70%64%66 Yes, this should be forbidden :-). Anyway, best solotion in such cases is to failback to Content-Type name. I am not sure if it is guaranted to be there, but probably it will. Leszek
Diffstat (limited to 'commands/msgview/save.go')
-rw-r--r--commands/msgview/save.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index 33cd45f7..99abe0e2 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -94,6 +94,8 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error {
save_dir = path
if filename, ok := p.Part.DispositionParams["filename"]; ok {
save_file = filename
+ } else if filename, ok := p.Part.Params["name"]; ok {
+ save_file = filename
} else {
timestamp := time.Now().Format("2006-01-02-150405")
save_file = fmt.Sprintf("aerc_%v", timestamp)