mailto: allow attaching of files
Some programs like Skanpage allow sharing files via email and attaching them automatically from the mailto: link. This patch introduces parsing of the attach query argument in mailto links and attaches the listed files. A potential file:// URL has it's prefix removed. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
ba24e92062
commit
87d856c10c
2 changed files with 11 additions and 0 deletions
|
@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Specify opener as the first `:open` param instead of always using default
|
- Specify opener as the first `:open` param instead of always using default
|
||||||
handler (i.e. `:open gimp` to open attachment in GIMP).
|
handler (i.e. `:open gimp` to open attachment in GIMP).
|
||||||
- Restored XOAUTH2 support for IMAP and SMTP.
|
- Restored XOAUTH2 support for IMAP and SMTP.
|
||||||
|
- Support for attaching files with `mailto:`-links
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -644,6 +644,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
|
||||||
var subject string
|
var subject string
|
||||||
var body string
|
var body string
|
||||||
var acctName string
|
var acctName string
|
||||||
|
var attachments []string
|
||||||
h := &mail.Header{}
|
h := &mail.Header{}
|
||||||
to, err := mail.ParseAddressList(addr.Opaque)
|
to, err := mail.ParseAddressList(addr.Opaque)
|
||||||
if err != nil && addr.Opaque != "" {
|
if err != nil && addr.Opaque != "" {
|
||||||
|
@ -679,6 +680,11 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
|
||||||
case "subject":
|
case "subject":
|
||||||
subject = strings.Join(vals, ",")
|
subject = strings.Join(vals, ",")
|
||||||
h.SetText("Subject", subject)
|
h.SetText("Subject", subject)
|
||||||
|
case "attach":
|
||||||
|
for _, path := range vals {
|
||||||
|
// remove a potential file:// prefix.
|
||||||
|
attachments = append(attachments, strings.TrimPrefix(path, "file://"))
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
// any other header gets ignored on purpose to avoid control headers
|
// any other header gets ignored on purpose to avoid control headers
|
||||||
// being injected
|
// being injected
|
||||||
|
@ -720,6 +726,10 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
|
||||||
}
|
}
|
||||||
ui.Invalidate()
|
ui.Invalidate()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for _, file := range attachments {
|
||||||
|
composer.AddAttachment(file)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue