aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* imap: strip whitespace from Message-Id and In-Reply-ToJulian Swagemakers27 hours2-7/+59
| | | | | | | | | | | | | | | | | | | | Outlook.com is generating fairly long Message-IDs and using folding[0] to put the ID on a new line. This is resulting in the Message-ID to contain a leading white space, which is preventing `TrimPrefix` from removing the less than symbol. When replying the In-Reply-To header will then contain "< <message-id>" which is not desired and prevents email clients or lists form correctly associating the email replied to. For example lore.kernel.org[1]. Trimming tabs, newlines, and spaces from Message-ID resolves the issue. [0]: https://datatracker.ietf.org/doc/html/rfc822#section-3.1.1 [1]: https://lore.kernel.org/git/D4U1RWVWEW5D.2T853XSBO1FPA@swagemakers.org/#t Changelog-fixed: Remove unwanted less than symbol from In-Reply-To header when Message-ID uses folding. Signed-off-by: Julian Swagemakers <julian@swagemakers.org> Acked-by: Robin Jarry <robin@jarry.cc>
* attach: fix content-transfer-encoding for rfc822 attachmentsKoni Marti27 hours1-0/+16
| | | | | | | | | | | | | | | | | | | | | | Fix the content-transfer-encoding for attachments with message/rfc822 mime types. It's not allowed by RFC2046 to set any other content-transfer-encoding than 7bit, 8bit, or binary for message/rfc822 mime types (see RFC2046, section 5.2.1). We can enforce this by setting a content-transfer-encoding header for attachments to 'binary' explicitly. 'binary' is more lenient than '8bit' with respect to line length and CRLF semantics and thus seems more suitable. Link: https://datatracker.ietf.org/doc/html/rfc2046#section-5.2.1 Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CD48A6YOQOXRG.3KKB6UTGMT8LY@maslowski.xyz%3E Reported-by: Piotr Masłowski <piotr@maslowski.xyz> Reported-by: inwit <inwit@sindominio.net> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* textinput: make completions run async with cancellationTim Culverhouse27 hours8-40/+67
| | | | | | | | | | | | | | | | | | Make the Completer interface accept a context.Context. Provide a cancellation feature on text input tab completion to cancel an inflight completion command. This is particularly useful for address book completion if the user has specified a network-accessing command, eg carddav-query. The command is started according to the completion delay, but is cancellable if another request comes in. We also check for cancellation after the request is complete to ensure we only show valid completion results. Changelog-changed: Tab completions for text fields are run asynchronously. In-flight requests are cancelled when new input arrives. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* history: read the history file from XDG_STATE_HOMETristan Partin27 hours2-2/+15
| | | | | | | | | | | History is more like application state than a cache you would just want to blow away. Let's reflect that in the path for the history file. Changelog-changed: The location of the command history file has changed to ${XDG_STATE_HOME:-$HOME/.local/state}/aerc/history. Signed-off-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc>
* completion: add command option descriptionsRobin Jarry3 days58-166/+155
| | | | | | | | | | | | | Add `desc:""` struct field tags in all command arguments where it makes sense. The description values will be returned along with completion choices. Implements: https://todo.sr.ht/~rjarry/aerc/271 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bojan Gabric <bojan@bojangabric.com> Tested-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* completion: add commands descriptionsRobin Jarry3 days94-14/+383
| | | | | | | | | | | | | | | Update the Command interface to include a Description() method. Implement the method for all commands using short descriptions inspired from the aerc(1) man page. Return the description values along with command names so that they can be displayed in completion choices. Implements: https://todo.sr.ht/~rjarry/aerc/271 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bojan Gabric <bojan@bojangabric.com> Tested-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* completion: display descriptions next to choicesRobin Jarry3 days34-88/+145
| | | | | | | | | | | | | | | | | | | | | | | | | Use go-opt v2 new completion API which returns items descriptions along with their text values. Display the descriptions after the items separated by two spaces. Wrap the descriptions in parentheses to better indicate that they are not part of the completion choices. Limit the description length to 80 characters to avoid display issues. Add a new style object completion_description in stylesets. By default, the object will be rendered with a dimmed terminal attribute. Update all stylesets and documentation accordingly. Implements: https://todo.sr.ht/~rjarry/aerc/271 Link: https://git.sr.ht/~rjarry/go-opt/commit/ebeb82538395a Changelog-added: Command completion now displays descriptions next to completion items. Changelog-added: New `completion_description` style object in style sets used for rendering completion item descriptions. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bojan Gabric <bojan@bojangabric.com> Tested-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* gpg: do not sign with untrusted keysMarcin Serwin3 days6-38/+82
| | | | | | | | | | | During encryption gpg was ignoring trust model of the user in favor of always using the insecure "always". This change removes this override and adds a helpful message if a user tries to encrypt a message with an untrusted key. To revert to the previous behavior users can add "trust-model always" to their gpg.conf file (default ~/.gnupg/gpg.conf). Signed-off-by: Marcin Serwin <marcin@serwin.dev> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* docs: fix typo for aerc-notmuch multi-file-strategyGary Kim3 days1-1/+1
| | | | | | | | | Fix a typo tin aerc-notmuch(5) where multi-file-strategy is misspelled as multi-file-stategy. Signed-off-by: Gary Kim <gary@garykim.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* viewer: avoid crashes on opening invalid messagesRobin Jarry3 days9-30/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an error occurs during the opening of a message because its contents cannot be parsed, the PartSwitcher object is left to nil and the err field is set to the reported error. This defers the error reporting after the viewer tab is displayed but it is not handled in all sub functions which assume that switcher cannot be nil. Error: runtime error: invalid memory address or nil pointer dereference git.sr.ht/~rjarry/aerc/app.(*PartSwitcher).Show(...) /build/aerc/src/aerc/app/partswitcher.go:77 git.sr.ht/~rjarry/aerc/app.(*MessageViewer).Show(...) /build/aerc/src/aerc/app/msgviewer.go:409 git.sr.ht/~rjarry/aerc/lib/ui.(*Tabs).selectPriv(...) /build/aerc/src/aerc/lib/ui/tab.go:181 git.sr.ht/~rjarry/aerc/lib/ui.(*Tabs).Add(...) /build/aerc/src/aerc/lib/ui/tab.go:75 git.sr.ht/~rjarry/aerc/app.(*Aerc).NewTab(...) /build/aerc/src/aerc/app/aerc.go:511 git.sr.ht/~rjarry/aerc/app.NewTab(...) /build/aerc/src/aerc/app/app.go:61 git.sr.ht/~rjarry/aerc/commands/account.ViewMessage.Execute.func1(...) /build/aerc/src/aerc/commands/account/view.go:71 git.sr.ht/~rjarry/aerc/lib.NewMessageStoreView.func1(...) /build/aerc/src/aerc/lib/messageview.go:80 git.sr.ht/~rjarry/aerc/lib.NewMessageStoreView(...) /build/aerc/src/aerc/lib/messageview.go:124 git.sr.ht/~rjarry/aerc/commands/account.ViewMessage.Execute(...) /build/aerc/src/aerc/commands/account/view.go:52 git.sr.ht/~rjarry/aerc/commands.ExecuteCommand(...) /build/aerc/src/aerc/commands/commands.go:205 main.execCommand(...) Remove that private err field and return an explicit error when the message cannot be opened to enforce handling of the error by the caller. When the msg argument is nil (only used in split viewer), return an empty message viewer object and ensure that all code paths that read the switcher or msg fields perform a nil check before accessing it. Link: https://lists.sr.ht/~rjarry/aerc-devel/%3C12c465e4-b733-4b15-b4b0-62f87429fdf7@gmail.com%3E Link: https://lists.sr.ht/~rjarry/aerc-devel/%3C2C55CF50-A636-46E5-9BA8-FE60A2303ECA@proton.me%3E Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CD51PEB6OMNDT.1KVSX0UCNL2MB@posteo.de%3E Reported-by: Benjamin Braun <ben.braun@posteo.de> Reported-by: Filip <filip.sh@proton.me> Reported-by: Sarthak Bhan <sbstratos79@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* invite: honor the -a flag for :sendinwit4 days1-1/+9
| | | | | | | | | | | | When sending replies to invitations with :accept, :accept-tentative or :decline, calling `:send -a` in the review screen does not archive the original invitation, as it should. Solve this situation and allow for directly archiving invitations after replying to them. Changelog-fixed: Invitations now honor the -a flag for :send. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* mk: fix debug cflagsRobin Jarry9 days1-1/+1
| | | | | | | The correct syntax to apply gcflags to all files is "all" not "*". Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* notmuch: fix explicit searches for excluded tagsMichael Adler9 days1-1/+3
| | | | | | | | | | | | | | Ensure that search queries containing tags from exclude-tags actually return messages by treating STATUS_IGNORED as an informational message rather than an error. For example, this covers the use-case where spam messages are ignored by default (exclude-tags = spam) and having a dedicated qmap entry allowing review of the possible spam messages: spam = tag:spam. Changelog-fixed: Notmuch searches which explicitly contain tags from `exclude-tags` now return messages. Signed-off-by: Michael Adler <michael.adler.oss@mailbox.org> Tested-by: Jason Cox <me@jasoncarloscox.com>
* mbox: handle invalid URL scheme in command lineSyed Fasiuddin9 days1-0/+8
| | | | | | | | | | | | | | Currently if `aerc mbox:..` is used on the command line with an invalid URL schema such as `aerc mbox:~/mbox`, it tries to open "nothing" and fails, instead of letting the user know that the URL scheme (command usage) is wrong. This commit silently handles such wrong URL schemes. Fixes: https://todo.sr.ht/~rjarry/aerc/281 Signed-off-by: Syed Fasiuddin <syed.fasiuddin@icloud.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* send: allow using envelope from addresshrdl2024-10-123-0/+12
| | | | | | | | | | Add a new boolean option in accounts.conf to use the envelope From address instead of the *from* configuration option when submitting via smtp, jmap or sendmail. Changelog-added: New `use-envelope-from` option in `accounts.conf`. Signed-off-by: hrdl <git@hrdl.eu> Acked-by: Robin Jarry <robin@jarry.cc>
* xdg: determine user runtime directory in a robust mannerRalph Seichter2024-10-121-1/+14
| | | | | | | | | | | | | Instead of relying on systemd-style /run/user/NNN directories, which are unavailable on platforms like OpenRC Gentoo Linux, create either the per user /tmp/aerc-NNN directory, or fall back to using /tmp as a last resort. Changelog-fixed: Failure to create IPC socket on Gentoo. Signed-off-by: Ralph Seichter <aerc@seichter.de> Reviewed-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* doc: fix formatting of reply -A flagJohannes Thyssen Tishman2024-10-121-1/+1
| | | | | | | | Fix small typo within docs. Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Acked-by: Robin Jarry <robin@jarry.cc>
* reply: make {{.OriginalText}} available to custom templatesJohannes Thyssen Tishman2024-10-122-11/+10
| | | | | | | | | | | | Currently {{.OriginalText}} is only available to the quote-reply template when using `:reply -q`. Allow templates specified using the `-T` flag to make use of it too. Changelog-changed: Templates passed to the `:reply` command using the `-T` flag can now make use of `{{.OriginalText}}`. Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Acked-by: Robin Jarry <robin@jarry.cc>
* config: add pinentry support to cred commandsKoni Marti2024-10-122-1/+28
| | | | | | | | | Add pinentry support for the source-cred-cmd and outgoing-cred-cmd. Do a little dance around an unallowed import cycle. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* crypto: add pinentry support to gpgKoni Marti2024-10-123-0/+14
| | | | | | | | | Add pinentry support to GPG for signing, enrypting and decrypting messages. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* aerc: support terminal-based pinentry programsKoni Marti2024-10-125-0/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support terminal-based pinentry programs. Suspend vaxis before running the command that can trigger a pinentry call. Provide the proper tty in the GPG_TTY environment variable (and set a TERM variable if not provided; this is necessary for pinentry-curses). Finally, resume vaxis. To enable terminal-based pinentry support, you have to set [general] use-terminal-pinentry = true in your aerc.conf. Any GUI-based pinentry programs will work the same as before if this option is not set to true. To test pinentry-tty, add the following to your ~/.gnupg/gpg-agent.conf: pinentry-program /usr/bin/pinentry-tty and kill all running gpg-agents: $ killall gpg-agent Fixes: https://todo.sr.ht/~rjarry/aerc/202 Changelog-fixed: Terminal-based pinentry programs (e.g. `pinentry-curses`) now work properly. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* aerc: add quake-mode terminalKoni Marti2024-10-087-15/+288
| | | | | | | | | | | | | | | | | | Add a drop-down (quake-mode) terminal which is a persistent terminal session that overlays aerc at the top and can be toggled on or off. Enable quake mode by setting [General].enable-quake-mode=true. The height of the drop-down terminal can be set with [ui].quake-terminal-height (default: 20). Toggling is hardcoded to the F1 key. Note that this key should not be used in your key bindings when you enable Quake mode. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* models: pad message uids with zeroesRobin Jarry2024-10-031-1/+1
| | | | | | | | | | | | | | IMAP message UIDs are 32 bits unsigned integers. All other backends use opaque strings without any specific ordering. The UIDs are used for ordering only for IMAP. Pad the integer uids with zeroes when converting them to strings to ensure ASCII sorting will work as previously. Fixes: 73dc39c6ee08 ("treewide: replace uint32 uids with opaque strings") Reported-by: Fedor Pchelkin <boddah8794@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Jens Grassel <jens@wegtam.com>
* calendar: skip editor when replying to invitationsinwit2024-10-032-3/+14
| | | | | | | | | | | Most of the time, accepting an invitation does not require editing the automatically generated email before sending it. Allow the user to optionally skip the editor entirely and go directly to the review screen when dealing with invitations. References: https://todo.sr.ht/~rjarry/aerc/247 Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* dirtree: fix dirlist-collapse=0 regressionRobin Jarry2024-09-201-1/+2
| | | | | | | | | Ensure not to collapse any folder when dirlist-collapse=0. Fixes: 73dc39c6ee08 ("treewide: replace uint32 uids with opaque strings") Reported-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* templates/quote: only prefix quoted lines with '>'Tim Culverhouse2024-09-201-1/+5
| | | | | | | | | | | | | | | | Prefix all quoted lines with depth > 1 with '>'. Quoted lines of depth 1 are quoted with "> ". This follows conventions of mailing lists which collapse quote depths without spaces. For example: >>> Quote depth 3 > Quote depth 1 >> Quote depth 2 Changelog-changed: Template function `quote` only prefixes with a space if at quote depth 1. Requested-by: Isaac Freund <mail@isaacfreund.com> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: update golangci-lint to 1.61.0Tristan Partin2024-09-209-20/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | golangci-lint 1.56 does not work with go 1.23. It causes obscure errors: [linters_context/goanalysis] buildir: panic during analysis: Cannot range over: func(yield func(K, V) bool), goroutine 4743 [running]: runtime/debug.Stack() /usr/lib/go/src/runtime/debug/stack.go:26 +0x5e github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1() /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_action.go:104 +0x5a panic({0x164b260?, 0xc00669b4a0?}) /usr/lib/go/src/runtime/panic.go:785 +0x132 honnef.co/go/tools/go/ir.(*builder).rangeStmt(0xc000051910, 0xc00a29cf00, 0xc009bf55c0, 0x0, {0x1af1960, 0xc009bf55c0}) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2214 +0x894 honnef.co/go/tools/go/ir.(*builder).stmt(0xc000051910, 0xc00a29cf00, {0x1af6970?, 0xc009bf55c0?}) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2427 +0x20a honnef.co/go/tools/go/ir.(*builder).stmtList(...) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:847 honnef.co/go/tools/go/ir.(*builder).stmt(0xc000051910, 0xc00a29cf00, {0x1af6880?, 0xc004f52ed0?}) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2385 +0x1415 honnef.co/go/tools/go/ir.(*builder).buildFunction(0xc000051910, 0xc00a29cf00) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2497 +0x417 honnef.co/go/tools/go/ir.(*builder).buildFuncDecl(0xc000051910, 0xc00622eea0, 0xc004f52f00) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2534 +0x189 honnef.co/go/tools/go/ir.(*Package).build(0xc00622eea0) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2638 +0xb46 sync.(*Once).doSlow(0xc009b81260?, 0xc009bf5bc0?) /usr/lib/go/src/sync/once.go:76 +0xb4 sync.(*Once).Do(...) /usr/lib/go/src/sync/once.go:67 honnef.co/go/tools/go/ir.(*Package).Build(...) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2556 honnef.co/go/tools/internal/passes/buildir.run(0xc000cf61a0) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/internal/passes/buildir/buildir.go:86 +0x18b github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc002d77d70) /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_action.go:190 +0x9cd github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2() /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_action.go:112 +0x17 github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc0007a5c70, {0x1859190, 0x7}, 0xc001c28f48) /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/timeutils/stopwatch.go:111 +0x44 github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc00212f680?) /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_action.go:111 +0x6e github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc002d77d70) /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xa5 created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze in goroutine 3468 /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x1e9 Update golangci-lint to 1.61.0 that works with go 1.23. It has new checkers that report errors that we need to fix: lib/crypto/gpg/gpgbin/gpgbin.go:226:22: printf: non-constant format string in call to fmt.Errorf (govet) return fmt.Errorf(strings.TrimPrefix(line, "[GNUPG:] ")) ^ worker/imap/observer.go:142:21: printf: non-constant format string in call to fmt.Errorf (govet) Error: fmt.Errorf(errMsg), ^ app/dirlist.go:409:5: S1009: should omit nil check; len() for []string is defined as zero (gosimple) if dirlist.dirs == nil || len(dirlist.dirs) == 0 { ^ app/dirtree.go:181:5: S1009: should omit nil check; len() for []*git.sr.ht/~rjarry/aerc/worker/types.Thread is defined as zero (gosimple) if dt.list == nil || len(dt.list) == 0 || dt.countVisible(dt.list) < y+dt.Scroll() { ^ app/authinfo.go:30:34: printf: non-constant format string in call to (*git.sr.ht/~rjarry/aerc/lib/ui.Context).Printf (govet) ctx.Printf(0, 0, defaultStyle, text) ^ app/authinfo.go:34:27: printf: non-constant format string in call to (*git.sr.ht/~rjarry/aerc/lib/ui.Context).Printf (govet) ctx.Printf(0, 0, style, text) ^ app/authinfo.go:62:34: printf: non-constant format string in call to (*git.sr.ht/~rjarry/aerc/lib/ui.Context).Printf (govet) x += ctx.Printf(x, 0, style, text) ^ Pretty much all of these errors are us passing non-const format strings to various methods. In C land, this is a large security issue. I would assume the same stands in Go. Thank you golangci-lint! Link: https://builds.sr.ht/~rjarry/job/1332376#task-validate-500 Signed-off-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc>
* commands: add an echo commandBence Ferdinandy2024-09-202-0/+29
| | | | | | | | | | | | | Currently if you want to explore what templates resolve to, it's a bit of pain. Add an echo command that doesn't do anything, other than prints the string that is its argument with the templates resolved. Implements: https://todo.sr.ht/~rjarry/aerc/277 Changelog-added: New `:echo` command that prints its arguments with templates resolved. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Reviewed-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc>
* mailmap: fix email typo for timRobin Jarry2024-09-041-0/+1
| | | | | | | This breaks my git-people script. Link: https://git.sr.ht/~rjarry/dotfiles/tree/main/item/bin/git-people Signed-off-by: Robin Jarry <robin@jarry.cc>
* treewide: replace uint32 uids with opaque stringsRobin Jarry2024-08-2864-649/+541
| | | | | | | | | | | | | | | | | Add a new models.UID type (an alias to string). Replace all occurrences of uint32 being used as message UID or thread UID with models.UID. Update all workers to only expose models.UID values and deal with the conversion internally. Only IMAP needs to convert these to uint32. All other backends already use plain strings as message identifiers, in which case no conversion is even needed. The directory tree implementation needed to be heavily refactored in order to accommodate thread UID not being usable as a list index. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* reload: reload everything if no flags are providedJason Cox2024-08-242-0/+9
| | | | | | | | | | | Currently, the :reload command silently does nothing if no flags are provided. Eliminate this confusion by reloading all reloadable configs in the absence of flags. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Reviewed-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* imap: fix SeqMap.Pop runtime errorKoni Marti2024-08-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix a runtime error in the SeqMap.Pop function causing a index-out-of-range panic: Version: 0.18.2.r22.gfff69046 (go1.22.6 amd64 linux 2024-08-10) Error: runtime error: index out of range [487] with length 487 goroutine 24430 [running]: runtime/debug.Stack() runtime/debug/stack.go:24 +0x5e git.sr.ht/~rjarry/aerc/lib/log.PanicHandler() git.sr.ht/~rjarry/aerc/lib/log/panic-logger.go:49 +0x66a panic({0x5dbf5a688020?, 0xc002ab0d80?}) runtime/panic.go:770 +0x132 git.sr.ht/~rjarry/aerc/worker/imap.(*SeqMap).Pop(0xc0003d4940, 0x1e8) git.sr.ht/~rjarry/aerc/worker/imap/seqmap.go:64 +0x17c git.sr.ht/~rjarry/aerc/worker/imap.(*IMAPWorker).handleImapUpdate(0xc0003d4820, {0x5dbf5a6dbd00, 0xc002068708}) git.sr.ht/~rjarry/aerc/worker/imap/worker.go:296 +0x26c git.sr.ht/~rjarry/aerc/worker/imap.(*IMAPWorker).drainUpdates.func1() git.sr.ht/~rjarry/aerc/worker/imap/flags.go:29 +0x10c created by git.sr.ht/~rjarry/aerc/worker/imap.(*IMAPWorker).drainUpdates in goroutine 52 git.sr.ht/~rjarry/aerc/worker/imap/flags.go:21 +0x78 SeqMap.Pop uses two locks in the same function: first lock grabs the size of the slice, second lock removes the given index in the slice. Combine the two locks to prevent a change of the slice size before the index can be removed. Reported-by: Moritz Poldrack <moritz@poldrack.dev> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch: add auto-switch optionKoni Marti2024-08-244-1/+133
| | | | | | | | | | | | | | | | | | | Add an auto-switch option that changes the project of the patch manager based on the subject line of a message if it contains a '[PATCH <project>]' segment. A subject line with '[PATCH aerc v2]' would switch to the 'aerc' project if that project is available in the patch manager. The auto switching can be activated per account by adding 'pama-auto-switch = true' to your account config. Implements: https://todo.sr.ht/~rjarry/aerc/226 Changelog-added: Auto-switch projects based on the message subject for the :patch command. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* gpg: fix signed message encodingKoni Marti2024-08-241-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the content encoding for GPG-signed messages. To remove the Mime-Version header field for the signed message part, the raw message is parsed with go-message. go-message.Read(), however, decodes the message body as well (i.e. from quoted-printable to UTF8 depending on the Content-Transfer-Encoding header). This means that the msg.Body field now contains the decoded message (it is no longer encoded as quoted-printable). We never encode the message back to the proper Content-Transfer-Encoding. To fix this, use net/mail.ReadMessage() to parse the headers and to not decode the message body. To verify the issue, send a signed message with the following text: "19+1=20!" The message will be properly signed, but the text is wrong; it shows "19+1 !"; instead it should read "19+1=3D20!". Fixes: 5e443bce ("gpg: fix mime-version header position") References: https://todo.sr.ht/~rjarry/aerc/79 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Jens Grassel <jens@wegtam.com> Acked-by: Robin Jarry <robin@jarry.cc>
* forward: better preserve attached file namesVitaly Ovchinnikov2024-08-241-2/+2
| | | | | | | | | | | Use a dedicated filename function for getting a name of the attached file instad of analyzing its mime type. Some attachments have file name in `Content-Disposition` rather than `Content-Type`, the new method handles both cases. Signed-off-by: Vitaly Ovchinnikov <v@ovch.ru> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: fetch created messages and set recent flagTim Culverhouse2024-08-241-21/+49
| | | | | | | | | | When a push notification arrives, automatically fetch any newly created messages. Set the Recent flag on these messages to trigger a notification in the UI. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: fix watcher pathThorben Günther2024-08-241-3/+14
| | | | | | | | | | | | | | The watcher path does not necessarily contain ".notmuch". From notmuch-config(1): Notmuch will store its database here, (in sub-directory named .notmuch if database.mail_root is unset). So we can simply check if the ".notmuch" folder exists and fallback to the default path if it does not. Signed-off-by: Thorben Günther <admin@xenrox.net> Acked-by: Robin Jarry <robin@jarry.cc>
* ircbot: sanitize email subjectsRobin Jarry2024-08-201-3/+5
| | | | | | | | | Email subjects may contain line breaks if they are too long to fit in 72 columns. The supybot library does not support sending messages with line breaks. It raises an error. Replace all consecutive "white space" characters (including \r and \n) with regular space characters. Signed-off-by: Robin Jarry <robin@jarry.cc>
* commands: add reloadKoni Marti2024-08-205-4/+199
| | | | | | | | | | | | | | Add the reload command that performs a reload of config files. The reload command supports reloading the binds.conf and aerc.conf config files. Reloading will reload account views (including the directory list), message viewers, and composers. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* store: extract configure logicKoni Marti2024-08-202-62/+60
| | | | | | | | | | Extract a function to configure the message store from its constructor to reconfigure the store when the data changes. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* account: update split viewsKoni Marti2024-08-201-2/+23
| | | | | | | | | | | Update split views on reload. Use the safe acct.SelectedMessage() instead of acct.msglist.Selected() which can panic if msglist.store is nil. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* account: extract configure logicKoni Marti2024-08-201-17/+22
| | | | | | | | | | Extract a function to configure the account view from the constructor; rebuild the grid whenever the config data changed on a hot-reload. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* account: remove ui config struct fieldKoni Marti2024-08-203-21/+18
| | | | | | | | | | Remove the UI config field in the AccountView struct to ensure we use the most current UI config. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* tabs: update ui config in any tabKoni Marti2024-08-202-26/+27
| | | | | | | | | Update UI config in tabs. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* log: handle config reloadKoni Marti2024-08-202-3/+48
| | | | | | | | | | | | Prepare the logging system for a config file reload. Make sure that we never close os.Stdout but only log file descriptors. Note that if you started aerc by redirecting its output into a specific file, this cannot be changed by a config reload. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* config: extract load styleset functionKoni Marti2024-08-201-19/+33
| | | | | | | | | | Extract the function to load stylesets. Add a function to clear the contextual UI cache. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* config: add reload helper functionsKoni Marti2024-08-204-4/+77
| | | | | | | | | | Add reload helper function to reload config files. Store the initially used config files for the reloading. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: refactor thread fetchingTim Culverhouse2024-08-202-40/+23
| | | | | | | | | | | | | | | | | | Refactor JMAP thread fetching to occur in a single request. We use a result reference method call on Email/get to fetch the message info for each message in a thread. Previously, we checked the cache and only fetched information for messages we didn't already have. This results in two requests and is typically slower for most contexts. Also, in most cases if we are fetching an email we don't already have it's because we also need to fetch the entire thread. The only case this wouldn't happen is if we get a new email in a thread. We can optimize this by fetching message info for created messages in the push method at a later time. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: lazily fetch identitiesTim Culverhouse2024-08-202-19/+33
| | | | | | | | | | | | | Fetch Identities only when required: when we are sending an email. Refactor connect.go to check the state string of the Session on every request, and update the session as needed. Move the Session validity check to happen on any request, eg when our client returns an error we first update the Session object (via re-authenticating) and then retry the request. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* maildir: set the forwarded flag when forwarding msgsinwit2024-08-203-7/+36
| | | | | | | | | | | The maildir backend was ignoring the passed/forwarded flag. Allow for this flag to be set and synced to the server (if the server admits it). Changelog-added: The maildir backend now honors the forwarded/passed flag. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>