67 Commits

Author SHA1 Message Date
Robin Jarry
bf9f3a4eff treewide: run go modernize
This is the result of the following command:

go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix ./...

Signed-off-by: Robin Jarry <robin@jarry.cc>
2025-12-20 18:06:30 +01:00
Robin Jarry
0ca8087ec9 treewide: replace interface{} with any
Since go 1.18, interface{} can be replaced with any.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Karel Balej <balejk@matfyz.cz>
2025-04-07 10:51:05 +02:00
Robin Jarry
3c9ad93801 completion: display descriptions next to choices
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>
2024-10-23 10:22:51 +02:00
Robin Jarry
73dc39c6ee treewide: replace uint32 uids with opaque strings
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>
2024-08-28 12:06:01 +02:00
inwit
93207b7330 maildir: set the forwarded flag when forwarding msgs
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>
2024-08-20 11:54:34 +02:00
jp39
e4ad97a3f0 search: fix crash during message search
Initialize info in SearchMessage irregardless of the message parts
flags otherwise it will crash when we attempt to read it in the next
switch statement.

Fixes: 8464b3738 ("search: use a common api for all workers")
Signed-off-by: jp39 <jp39@gmx.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-04-02 22:22:00 +02:00
Robin Jarry
8edf7b0e4d log: move package to lib
This has nothing to do at the root of the source tree.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
2024-02-14 23:04:38 +01:00
Koni Marti
e7c26e02bb filter: allow workers to combine filter terms
Allow the backend workers to combine the filter terms. Currently, the
consecutive filters are joined in the message store with a space (" ").
This works well for most backends, but makes the filter combination for
notmuch confusing.

Example:

Issuing two consecutive filter commands in notmuch

	:filter not tag:list
	:filter tag:list

would create the following filter query

	'not tag:list tag:list'

This is not what users would expect; they expect:

	'(not tag:list) and (tag:list)'

Note that the notmuch backend works correctly for the given query, but
produced a query that does not match the user's expectation. This patch
fixes this.

The combination of filter terms in other backends remains the same.

Reported-by: Ángel Castañeda <angel@acsq.me>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-02-11 22:03:56 +01:00
Jason Cox
11b035f120 flags: add support for draft flag
Support the draft flag wherever flags are used. Automatically set it
when postponing a message, and allow recalling a message without the -f
flag if it has the draft flag set, regardless of what folder it's in.

Notmuch doesn't seem to pick up on the draft flag when indexing even
though the flag is set on the maildir file. Explicitly set all tags
corresponding to set flags when appending a message in notmuch.

Changelog-added: Support the `draft` flag.
Signed-off-by: Jason Cox <me@jasoncarloscox.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-01-26 21:36:15 +01:00
Koni Marti
063187340c search: add rcpts fields to header in search criteria
Add recipients fields (from, to, cc) to the header for filtering and
searching for the maildir and mbox backends.

Fixes: commit 8464b373 ("search: use a common api for all workers")
Reported-by: Vitaly Ovchinnikov <v@ovch.ru>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Tested-by: Vitaly Ovchinnikov <v@ovch.ru>
2023-11-12 12:53:11 +01:00
Robin Jarry
8464b37385 search: use a common api for all workers
Define a SearchCriteria structure. Update the FetchDirectoryContents,
FetchDirectoryThreaded and SearchDirectory worker messages to include
this SearchCriteria structure instead of a []string slice.

Parse the search arguments in a single place into a SearchCriteria
structure and use it to search/filter via the message store.

Update all workers to use that new API. Clarify the man page indicating
that notmuch supports searching with aerc's syntax and also with notmuch
specific syntax.

getopt is no longer needed, remove it from go.mod.

NB: to support more complex search filters in JMAP, we need to use an
email.Filter interface. Since GOB does not support encoding/decoding
interfaces, store the raw SearchCriteria and []SortCriterion values in
the cached FolderContents. Translate them to JMAP API objects when
sending an email.Query request to the server.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Tested-by: Inwit <inwit@sindominio.net>
2023-10-28 19:24:59 +02:00
Robin Jarry
57088312fd worker: move shared code to lib
Avoid importing code from worker/lib into lib. It should only be the
other way around. Move the message parsing code used by maildir,
notmuch, mbox and the eml viewer into a lib/rfc822 package.

Adapt imports accordingly.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Tested-by: Inwit <inwit@sindominio.net>
2023-10-28 19:24:55 +02:00
Vitaly Ovchinnikov
d2f92473b3 sort: new flagged sorting criteria
Add new `flagged` criteria to `:sort` command (and apparently to the
`sort` config option). Good for moving important stuff up.

Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2023-10-13 00:40:53 +02:00
Tim Culverhouse
d57aa9e582 lib: return a new Header from LimitHeaders
The LimitHeaders function is used to optionally reduce memory usage of
aerc by only keeping certain headers in memory for the message list. The
function properly deletes header keys and values from the underlying
object, however the underlying data structure has a map and a slice -
which do not get resized after deletion: resulting in no actual memory
savings.

Create a new header and add only the headers we want to it. Return this
value and use in the MessageInfo struct.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2023-09-19 01:16:52 +02:00
Robin Jarry
a3e811e00d watchers: move filesystem monitoring stuff in lib
No functional change. This will allow reuse in other parts of aerc.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Koni Marti <koni.marti@gmail.com>
2023-08-04 11:32:40 +02:00
Koni Marti
822bd3620a lib: parse query-map and folder-map files
Combine the query-map and folder-map parsing functionality. Add tests.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-06-22 10:55:25 +02:00
Tim Culverhouse
6b6aaf3ae1 headers: enable partial header fetching
Enable partial header fetching by creating config values for headers to
specifically include, or specifically exclude. The References field will
always be fetched, regardless of the include list. Envelope data is
always fetched, but is not shown with :toggle-headers, since it isn't in
the RFC822 struct unless explicitly included in the list.

Partial headers can break the cache on changes. Update the cache tag key
to include the state of the partially-fetched headers.

Partial header fetching can have a significant performance increase for
IMAP, and for all backends a resource improvement. Some data to support
this is below. Gathered by opening aerc, selecting a mailbox with
approximately 800 messages and scrolling to the end.

Received measured with nethogs, RAM from btop

		   Received  |   RAM
-------------------------------------
All Headers	|   9,656 kb | 103 MB
Minimum Headers	|     896 kb |  36 MB

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2023-05-16 17:07:50 +02:00
Koni Marti
f04d83e80a messageinfo: report message sizes
Report sizes of the message across all backends.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2023-04-26 00:07:43 +02:00
Julian Marcos
96d5b4e149 search: handle headers in search/filter query
Handle headers in the search and filter commands, for searching and
filtering based on the Headers specified by the -H parameter, the syntax
for the -H parameter should be `Header: Key`.

Signed-off-by: Julian Marcos <jmjl@tilde.green>
Acked-by: Robin Jarry<robin@jarry.cc>
2023-04-22 22:50:37 +02:00
Nguyễn Gia Phong
94a763920f parse msg-id lists more liberally
Some user agents deliberately generate non-standard
message identifier lists in In-Reply-To and References headers.

Instead of failing silently, aerc now falls back to a desperate parser
scavaging whatever looking like <id-left@id-right>.

As the more liberal parser being substituted with, References header
are now stored for IMAP not only when there's a parsing error.

Fixes: 31d2f5be3c ("message-info: add explicit References field")
Signed-off-by: Nguyễn Gia Phong <mcsinyx@disroot.org>
Acked-by: Robin Jarry <robin@jarry.cc>
2023-03-26 21:02:18 +02:00
Robin Jarry
60078b8452 fswatcher: fix bsd support
Fix the following error when running maildir on freebsd:

 could not create file system watcher: Unsupported OS: freebsd

Do not register based on os type. Register based on supported API.
Rename linux -> inotify and darwin -> fsevents. Only build fsevents on
darwin, and inotify on all other platforms.

Fixes: a0935a3de0 ("worker/lib: implement an fswatcher interface")
Reported-by: Jens Grassel <jens@wegtam.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Jens Grassel <jens@wegtam.com>
2023-03-10 09:19:09 +01:00
Tim Culverhouse
27cacdfca5 fswatcher: add a darwin fswatcher implementation
Add a darwin implementation of FSWatcher using the fsevents package. The
implementation is behind a darwin build flag.

Co-authored-by: Ben Cohen <ben@bencohen.net>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Ben Lee-Cohen <ben@lee-cohen.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2023-03-07 16:37:02 +01:00
Tim Culverhouse
a0935a3de0 worker/lib: implement an fswatcher interface
Implement an FSWatcher interface. The interface is used to abstract away
file system watchers, which have implementation specific backends. The
initial interface has one implementation: inotify for linux. Subsequent
commits will add a macOS watcher.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Ben Lee-Cohen <ben@lee-cohen.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2023-03-07 16:37:02 +01:00
Robin Jarry
30d8f8dd21 lint: always run golangci-lint@latest
Do not store the dependency in tools.go as there may be conflicts with
some indirect dependencies of aerc.

Run gofumpt and golangci-lint from their latest tagged release. This
should fix issues with go 1.20. Bonus, it drains a bit of fat from
go.sum.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2023-02-26 21:48:43 +01:00
Robin Jarry
5677f93ff8 model: change flags array to bitmask
Using a list of integers is not optimal. Use a bit mask instead.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2023-01-04 22:57:31 +01:00
Koni Marti
d547dca676 daterange: support relative terms
Support relative terms when writing date ranges in the search and filter
commands with the -d flag. Syntax is inspired by the notmuch search
terms.

Terms can be written with spaces or underscores for a better
readability, so both "this_week" and "this week" are allowed. Terms are
not case-sensitive.

Some terms can be prefixed with either "this" or "last" where applicable
("this" is assumed by default if omitted):

- "today", "yesterday"
- ("this"|"last") "year", "month", "week"
- all weekdays (e.g. "Tuesday", "last_wed")
- all months  (e.g. "January", "last_feb")

Note that "month" should always be spelled out to prevent a possible
ambiguity with "Monday".

Weekdays and months do not need to be written out completely, i.e.
"February..March" and "Feb..Mar" are both understood.

Relative date terms can be used with the <N (year|month|week|day)>
syntax where N is a positive integer indicating the number of time units
in the past from today. The units can be abbreviated with a single
letter, e.g. "1w 1d.." is the same as "1 week 1 day..".

More examples:
:filter -d yesterday
:filter -d last_monday..
:filter -d mon..sat
:filter -d 1y1m1w1d..
:search -d this_week "PATCH aerc"

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-12-02 22:59:44 +01:00
Koni Marti
ff101bda43 search: handle date ranges in search/filter query
Handle date ranges in the filter and search commands for searching and
filtering based on the Date: header. Implement a flag (-d) that accepts
a date range <start[..end]> where the start date is included in the
range but the end date is not, i.e. [start,end).

The start or end date can be omitted: "start", "start..", "..end", or
"start..end" are all valid inputs.

An example filter query would look like this: :filter -d 2022-11-09..

The dates should be in the YYYY-MM-DD format.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-12-02 22:59:23 +01:00
Robin Jarry
23a05d17ac logging: rename package to log
Use the same name than the builtin "log" package. That way, we do not
risk logging in the wrong place.

Suggested-by: Tim Culverhouse <tim@timculverhouse.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2022-12-02 22:10:49 +01:00
Koni Marti
1352942056 maildir: fallback when parsing for in-reply-to fails
Fallback to just using the raw In-Reply-To header content when it cannot
be properly parsed as a message-id.

Fixes: ca903d4228 ("envelope: add InReplyTo field")
Reported-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
2022-11-13 17:14:04 +01:00
Tim Culverhouse
31d2f5be3c message-info: add explicit References field
Add an explicit References field to message info. This is useful for
storing information needed for threading without storing all of the
header values, keeping system RAM usage lower.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-11-09 21:26:45 +01:00
Tim Culverhouse
ca903d4228 envelope: add InReplyTo field
A standard IMAP envelope response includes the In-Reply-To header field.
Add this field to the aerc model of Envelope. Update envelope parser to
set this value. Update imap worker to set this value.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-11-09 21:26:34 +01:00
Tim Culverhouse
59510c41c8 maildir: keep less data in memory for sorting
Sorting opens and reads portions of every file within a directory in
order to gather the data needed. Specifically, RFC822Headers and
BodyStructure are not needed. The RFC822Headers field stores a lot of
information, and the BodyStructure field requires parsing the body of
the email.

Don't set these two values when parsing.

Note: in my testing, this dropped sorting a 52k archive from 2.2gb of
ram usage, to < 500mb

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-11-06 23:18:01 +01:00
Julian Pidancet
ea10b329dd maildir: replace ListFolder method with FolderMap
Replace ListFolder with a new method that returns a map indexed by
folder names instead of a list of folder names. A map is simpler to use
and more efficient in case we only want to check the presence of a
specific folder in the Maildir store.

Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2022-10-27 21:39:41 +02:00
Julian Pidancet
f021bfd1c7 maildir: move common maildir code out of worker
This change moves code that could be common to both notmuch and maildir
workers in worker/lib.

Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2022-10-27 21:39:41 +02:00
Robin Jarry
ebcd6fcea1 lint: check for bad white space habits
A little coding hygiene cannot hurt. Add a simple awk script to check
all source files for bad white space habits:

- trailing white space
- trailing new lines at the end of files
- missing new line at the end of files
- spaces followed by tabs

The script outputs color when the terminal supports it. It exits with
a non-zero code when there was at least one white space issue found.
Call the script in the lint step.

Example output of the awk script:

 config/default_styleset:1:# <-- trailing whitespace
 config/default_styleset:3:# <-- trailing whitespace
 doc/aerc.1.scd:78:        Executes an arbitrary command in the background. Aerc will set the <-- trailing whitespace
 doc/aerc.1.scd:234:        <-- trailing whitespace
 doc/aerc.1.scd:237:        <-- trailing whitespace
 worker/types/thread_test.go:74:        //         return ErrSkipThread<-- space(s) followed by tab(s)
 worker/lib/testdata/message/invalid/hexa: trailing new line(s)

Fix issues reported by the script.

NB: The ENDFILE match is a GNU extension. It will be ignored on BSD-awk
and trailing new lines will not be detected. The lint make target is
only invoked on alpine linux which has GNU awk anyway.

NB: Empty cells in scdoc tables require trailing white space... Avoid
this by setting content in these cells. I don't really see a use for
empty cells.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
2022-10-19 10:19:19 +02:00
Koni Marti
684ceed2cd lib: parse address header fields to utf-8
When parsing address header fields, the field charset is automatically
decoded to UTF-8. If the charset is unknown, use the raw field value.

Fixes: https://todo.sr.ht/~rjarry/aerc/91
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
2022-09-29 16:51:53 +02:00
Koni Marti
e5b0725824 charset: handle unknown charsets more user-friendly
Do not throw an error when the charset is unknown; the message entity
can still be read, but log the error instead.

Reported-by: falsifian
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-09-25 11:54:23 +02:00
Thomas Faughnan
5ed849688a parse: remove trailing whitespace from rfc1123z regex
When there is no Date header in a message, aerc falls back to the
Received header and tries to extract an rfc1123z date from it
(introduced in commit d1600e46). The current regex for extracting the
date incorrectly allows for trailing whitespace, causing time.Parse() to
fail inside of parseReceivedHeader(). As a result, the message's date is
shown as "???????????????????" in the message list and as
"0000-12-31 07:03 PM" in the message view (the latter is likely related
to the zero value of time.Time).

Steps to reproduce:
1) Send yourself a message with no Date header, e.g. with msmtp:
printf 'Subject: foo bar\n\nbody text\n' | msmtp --set-date-header=off me@example.com
2) Note the message's displayed date in aerc's message list and message
   view.

Signed-off-by: Thomas Faughnan <tom@tjf.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-22 15:46:56 +02:00
Moritz Poldrack
9cffc45f03 go: removed io/ioutil
Since the minimum required version of Go has been bumped to 1.16, the
deprecation of io/ioutil can now be acted upon. This Commit removes the
remaining dependencies on ioutil and replaces them with their io or os
counterparts.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-22 09:30:19 +02:00
Robin Jarry
6b1afc3ae3 tests: fix errors after lint series
Fix the following test failures:

 FAIL: TestMessageInfoHandledError (0.00s)
 parse_test.go:53: could not parse envelope: date parsing failed:
 unrecognized date format:

 FAIL: TestReader (0.07s)
 gpg_test.go:27: using GNUPGHOME = /tmp/TestReader2384941142/001
 reader_test.go:108: Test case: Invalid Signature
 reader_test.go:112: gpg.Read() = gpgmail: failed to read PGP
 message: gpg: failed to run verification: exit status 1

Fixes: 5ca6022d00 ("lint: ensure errors are at least logged (errcheck)")
Fixes: 70bfcfef42 ("lint: work nicely with wrapped errors (errorlint)")
Signed-off-by: Robin Jarry <robin@jarry.cc>
Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
2022-08-04 22:52:40 +02:00
Moritz Poldrack
70bfcfef42 lint: work nicely with wrapped errors (errorlint)
Error wrapping as introduced in Go 1.13 adds some additional logic to
use for comparing errors and adding information to it.

Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-04 21:58:04 +02:00
Moritz Poldrack
978d35d356 lint: homogenize operations and minor fixes (gocritic)
Apply GoDoc comment policy (comments for humans should have a space
after the //; machine-readable comments shouldn't)

Use strings.ReplaceAll instead of strings.Replace when appropriate

Remove if/else chains by replacing them with switches

Use short assignment/increment notation

Replace single case switches with if statements

Combine else and if when appropriate

Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-04 21:58:01 +02:00
Moritz Poldrack
aaf0a0c656 lint: apply new formatting rules
Run `make fmt`.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-01 10:44:52 +02:00
Koni Marti
a1a276e002 mbox: implement an mbox backend worker
Implement an mbox backend worker. Worker can be used for testing and
development by mocking a backend for the message store. Worker does not
modify the actual mbox file on disk; all operations are performed in
memory.

To use the mbox backend, create an mbox account in the accounts.conf
where the source uses the "mbox://" scheme, such as

source = mbox://~/mbox/

or

source = mbox://~/mbox/file.mbox

If the mbox source points to a directory, all files in this directory
with the .mbox suffix will be opened as folders.

If an outgoing smtp server is defined for the mbox account, replies can
be sent to emails that are stored in the mbox file.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-14 23:14:45 +02:00
Koni Marti
955f7683af parse: fix content-type parsing error
If an error occurs when parsing the content-type, check if the
content-type is quoted; if so, remove quotes. If this is not the case,
then return a text/plain content-type as a sane fallback option, so that
the message can be at least viewed in plaintext.

Fixes: https://todo.sr.ht/~rjarry/aerc/44
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-06-07 16:19:27 +02:00
Koni Marti
698c0957d7 pgp: ensure CRLF line endings in pgpmail reader
Ensure CRLF line endings in the pgpmail reader. Fix the pgp signature
verification for maildir and notmuch.

These backends do not return the full message body with CRLF
line endings. But the accepted OpenPGP convention is for signed data to
end with a <CR><LF> sequence (see RFC3156).

If this is not the case the signed and transmitted data are considered
not the same and thus signature verification fails.

Link: https://datatracker.ietf.org/doc/html/rfc3156

Reported-by: Tim Culverhouse <tim@timculverhouse.com>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
2022-04-25 12:31:33 +02:00
Moritz Poldrack
e30bd324a3 go vet: composite literal uses unkeyed fields
This commit fixes all occurrences of the abovementioned lint-error in
the codebase.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-18 13:33:16 +01:00
Nguyễn Gia Phong
904ffacb0e maildir,notmuch: avoid leaking open files
Previously, Message.NewReader returned the wrapped buffered reader
without a reference to the opened file, so the files descriptors
were left unclosed after reading.  Now, the file reader is returned
directly and closed on the call site.  Buffering is not needed here
because it is an implementation detail of go-message.

Fixes: https://todo.sr.ht/~rjarry/aerc/9
2022-01-19 20:18:00 +01:00
Robin Jarry
0d645bcebd go.mod: change base git url
I'm not sure what are the implications but it seems required.

Link: https://github.com/golang/go/issues/20883
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-05 10:21:45 +01:00
Reto Brunner
fda424bebc lib/parse: simplify parseAddressList 2021-02-22 11:47:31 +01:00