diff options
author | Robin Jarry <robin@jarry.cc> | 2023-06-29 09:21:04 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-07-15 17:51:33 +0200 |
commit | 8dcb58c81782a30f06794227cf9a1b54928134e3 (patch) | |
tree | e11226a2a9b4d4a164879ea4755823c6ac08436a /widgets/account-wizard.go | |
parent | 7a674312b6f006be7c1241b10cf9063841aa1d9c (diff) | |
download | aerc-8dcb58c81782a30f06794227cf9a1b54928134e3.tar.gz |
wizard: properly initialize configuration
The wizard constructs an AccountConfig object by hand without
initializing default values. This causes a crash when replying to an
email (rr) just after completing the account creation:
~/.config/aerc/aerc.conf not found, installing the system default~/.config/aerc/binds.conf not found, installing the system defaultpanic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x90 pc=0x5d1550]
...
regexp.(*Regexp).doExecute(0x7fc1089aa108?, {0x0?, 0x0?}, {0x0?, 0x0?, 0xc000fe5408?}, {0xc000698120?, 0x10?}, 0xad3a40?, 0x2, ...)
regexp/exec.go:527 +0x90
regexp.(*Regexp).FindString(0x44e372?, {0xc000698120, 0x27})
regexp/regexp.go:852 +0x6c
git.sr.ht/~rjarry/aerc/commands/msg.trimLocalizedRe({0xc000698120, 0x27}, 0xc00003e420?)
git.sr.ht/~rjarry/aerc/commands/msg/reply.go:332 +0x36
git.sr.ht/~rjarry/aerc/commands/msg.reply.Execute({}, 0xc0002ba180, {0xc0002f8800?, 0x2, 0x2})
git.sr.ht/~rjarry/aerc/commands/msg/reply.go:157 +0x765
...
Extract the account parsing and initialization into a function. Reuse
that function in both accounts.conf parsing and the wizard.
Fixes: 40cc540357d9 ("reply: allow to override localized Re regexp in configuration")
Reported-by: Mechiel Lukkien <mechiel@ueber.net>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Andrew Yu <andrew@andrewyu.org>
Diffstat (limited to 'widgets/account-wizard.go')
-rw-r--r-- | widgets/account-wizard.go | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go index 9ad814b5..8c9739e6 100644 --- a/widgets/account-wizard.go +++ b/widgets/account-wizard.go @@ -13,7 +13,6 @@ import ( "sync" "time" - "github.com/emersion/go-message/mail" "github.com/gdamore/tcell/v2" "github.com/go-ini/ini" "github.com/kyoh86/xdg" @@ -531,25 +530,14 @@ func (wizard *AccountWizard) finish(tutorial bool) { } } - from, err := mail.ParseAddress(sec.Key("from").String()) + account, err := config.ParseAccountConfig(sec.Name(), sec) if err != nil { wizard.errorFor(nil, err) return } + config.Accounts = append(config.Accounts, account) - account := config.AccountConfig{ - Name: sec.Name(), - Default: "INBOX", - From: from, - Source: sec.Key("source").String(), - Outgoing: config.RemoteConfig{Value: sec.Key("outgoing").String()}, - } - if wizard.copySent { - account.CopyTo = "Sent" - } - config.Accounts = append(config.Accounts, &account) - - view, err := NewAccountView(wizard.aerc, &account, wizard.aerc, nil) + view, err := NewAccountView(wizard.aerc, account, wizard.aerc, nil) if err != nil { wizard.aerc.NewTab(errorScreen(err.Error()), account.Name) return |