mailto: allow empty recipient field

Allow a mailto link to open a new composer even if no recipient is in
the url.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Moritz Poldrack <git@moritz.sh>
This commit is contained in:
Tim Culverhouse 2022-03-17 19:36:19 -05:00 committed by Robin Jarry
parent a0fceb80b3
commit 62a5ebb1e1

View file

@ -527,7 +527,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
var subject string var subject string
h := &mail.Header{} h := &mail.Header{}
to, err := mail.ParseAddressList(addr.Opaque) to, err := mail.ParseAddressList(addr.Opaque)
if err != nil { if err != nil && addr.Opaque != "" {
return fmt.Errorf("Could not parse to: %v", err) return fmt.Errorf("Could not parse to: %v", err)
} }
h.SetAddressList("to", to) h.SetAddressList("to", to)
@ -567,6 +567,9 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
title = subject title = subject
composer.FocusTerminal() composer.FocusTerminal()
} }
if to == nil {
composer.FocusRecipient()
}
tab := aerc.NewTab(composer, title) tab := aerc.NewTab(composer, title)
composer.OnHeaderChange("Subject", func(subject string) { composer.OnHeaderChange("Subject", func(subject string) {
if subject == "" { if subject == "" {