[PATCH] handle attachment filenames starting with "-"

6 views
Skip to first unread message

James Cook

unread,
Jan 30, 2025, 8:38:01 PM1/30/25
to mbl...@googlegroups.com
From a brief IRC discussion Dec 7:

If when editing in mcom/mfwd I write an "attach" line with a filename
starting with -t, I see "file: unknown option -- t" before the "what
now?" prompt. (I encountered this naturally when I tried to attach
a file that some online service had decided to name "-tickets.pdf".)

The below patch fixes it, following Leah's suggestion on IRC.

Based an a quick look, contrib/msendmail might benefit from a similar
patch, but I don't use that tool so I haven't tried.

I also noticed I can't run e.g. "mcom -attach -t", I guess due to
the way option parsing works. My patch doesn't address that.

--
James


diff f3630678e020af0e5db451202a765fc3fb8eb1d5 ff89bebd73f31d3b7b0d1d76b1f6525e19729390
commit - f3630678e020af0e5db451202a765fc3fb8eb1d5
commit + ff89bebd73f31d3b7b0d1d76b1f6525e19729390
blob - 4b0f4f803436372b6ab4dd77acd1eb67e524a682
blob + 992af24e609b07dfdc5ec90a2be9a65a67b744f3
--- mcom
+++ mcom
@@ -85,7 +85,7 @@ do_mime() {
msed '/attach/d' "$draft"
for f in $(mhdr -M -h attach "$draft"); do
printf '#%s %s\n' \
- "$(file -Lb --mime "$f" | sed 's/ //g')" \
+ "$(file -Lb --mime -- "$f" | sed 's/ //g')" \
"$f"
done
) | mmime >"$draftmime"
Reply all
Reply to author
Forward
0 new messages