Age | Commit message (Collapse) | Author |
|
This makes it a bit clearer what the assignment is doing, and reduces
direct dptr manipulation a bit.
|
|
Some callers performed a mutt_buffer_init(), called
mutt_extract_token() and then assumed that the buffer->data would
never be NULL. Prior to the "fix" in commit f420be68, this was not
true, even if MoreArgs() returns true, because the argument could be
just ''.
The parse_keymap() change fixed a possible segv. Don't use the buffer
pool, because it returns buf->data to the caller.
I don't believe the other two would segv, but they did still rely on
the old behavior where the the buffer would have a '\0' appended
always. So, change them to use the buffer pool to be cleaner.
|
|
|
|
Commit e5a32a61 removed a 'mutt_buffer_addch (dest, 0)' at the end of
the function. Most callers had been converted to use the buffer pool,
and the call was strange since buffers self-terminate.
However, this line covered up logic errors in some of the callers,
which assumed the buffer->data could not be NULL afterwards.
I will try to fix up callers with the logic errors in master. This is
to fix the problem in stable, and also ensure future callers don't
make the same mistake.
|
|
|
|
Commit 4e153adf changed this code to reuse the function buffer
variable, but forgot to rewind the buffer for parsing in
parse_my_hdr().
Additionally commit e5a32a61 removed an extra "null termination"
mutt_buffer_addch() at the end of mutt_extract_token(). This caused a
NULL value to be passed to the strpbrk() in parse_my_hdr(), causing a
segv. Change to use a buffer pool token parameter instead.
I actually think, like with the previous IMAP mailbox handling, this
method of adding a my_hdr is dangerous. I'll look into refactoring it
in master instead.
Thanks to Paul Nevai for reporting the problem and tracking down the
backtrace.
|
|
start_debug() takes a boolean indicating whether to rotate debug
files.
The -d option allows a negative number. If negative, debug files
are not rotated. The debug level is the absolute value.
This is useful for continuously watching (e.g. tail -f) the
.muttdebug0 file.
|
|
Commit 5c5c34f2 made back in 1.6 changed Fqdn setting to use
gethostname() and getaddrinfo() to get the canonical domain. This is
more accurate but can cause startup delays for systems where the DNS
resolution is not set up properly.
Because this occurred before muttrc reading, there was no workaround
except to "fix DNS".
Change Fqdn ($hostname) setting to occur after the muttrc and '-e'
argument processing occur.
This is a possible breaking change if users rely on $hostname inside
their muttrc, for example 'source "muttrc.$hostname"'. The workaround
would be to put something like (depending on the system type): 'set
hostname = `hostname --fqdn`' in the muttrc above that invocation.
Also note that we still set Hostname (the internal variable) early,
because it is used in more places than Fqdn, such as tempfiles.
|
|
- Instead of relying on random() implementations which can be of
questionable quality or relying on the presence of /dev/urandom, we
implement our own PRNG implementation that uses the LFRS113 PRNG algorithm
by Pierre L'Ecuyer.
We seed this PRNG with values based on time, pid and ppid. It is OK if not
all seeds are of the highest quality as all four seeds would have to be
known to predict the numbers generated. In addition to this, we also use
/dev/urandom values (if available) that we mix into our four seeds.
In case we are reseeding we will also reuse our existing state information
for setting the new seed values.
- Add a function to Base64 encode 96 random bits
|
|
Relative expansion shouldn't be performed when those values are to be
executed as a pipe for the output.
I believe this issue only affects $signature and the source command,
so for now I'm disabling relative expansion for those two cases. If
there is too much more breakage, I will consider backing out the
relative expansion and disabling the :cd command.
Thanks to Aaron Schrab for reporting this issue.
|
|
Some paths, such as the folder browser, or certain hook values,
should be expanded for shortcuts, but not for relative paths.
Configuration variables that hold commands that search by PATH should
also not be expanded.
Create a separate call, and a separate data type for config vars.
|
|
This is important for MuttLisp, where the current value could be used
to determine the new assignment.
|
|
MoreArgs() doesn't look for whitespace, and so assumes
mutt_extract_token() will remove trailing whitespace too.
|
|
This is somewhat simple enhancement to muttrc processing, not a
full-blown embedded scripting language. There are no variables,
functions, types, or abilities that compete with macros.
MuttLisp can be invoked using the "run" command. If
$muttlisp_inline_eval is set, it can also be invoked with a bare
parenthesis expression as a command argument.
$muttlisp_inline_eval defaults unset, to avoid breaking existing
configurations, which might have bare parenthesis arguments for
regexps.
|
|
|
|
I'm not sure if this is possible because of the way the input is read
by the muttrc parser, but fix the logic to ensure it can't happen.
|
|
From my email to mutt-dev:
I've been thinking about this a *lot* more, and digging into past
commits. It looks like the escaping has pretty consistently been
intended for value completion and queries. See commits 3c00eb7a and
032dcbeb.
I don't believe the escaping is useful for variable expansion as
part of mutt_extract_token() - even for the hook "command" argument
case. The escaping is targeted only for an expression surrounded by
double quotes (as is generated by completion and queries). It
doesn't escape single quotes or spaces, for instance.
Thanks also to Oswald Buddenhagen and Cameron Simpson for their
feedback.
|
|
The "command" parameter of folder, send, send2, account, reply, and
message hooks is run through mutt_extract_token() twice. Once when
parsing the hook command initially, and once via mutt_parse_rc_line()
when the actual hook fires.
In theory, Mutt users should be aware of this, and should place all
their command strings with configuration variables in single-quotes,
to delay expansion until execution.
But in reality Mutt has been escaping configuration variables as part
of mutt_extract_token() for many years.
The previous commit turned the escaping off, because it damages
"backup" assignments to a $my_ variable, and I believe is confusing
behavior.
But for hooks, users now expect the escaping behavior (for
double-quoted or unquoted command strings).
Note that mutt_parse_hook() also passed the MUTT_TOKEN_SPACE flag, but
neglected to do so for message-hook. Since all other "command"
argument hooks were included, and were added to the list over the
years, I believe this was an accidental oversight.
|
|
Inside mutt_extract_token(), expanding a configuration variable used a
fixed size LONG_STRING. This would truncate long values, such as
oauth_refresh, which may have a large token embedded in them.
Convert var_to_string() to use a BUFFER parameter instead.
var_to_string() also performed escaping, which is not always helpful.
Disable the escaping inside. Add it back in
mutt_var_value_complete(), via the pretty_var() call.
The escaping may also be useful for hook "command" parameters. Since
Mutt has had the escaping behavior there for years, removing it will
likely break configurations. This will be added back in the next
commit.
|
|
Translate them once in mutt_set_default().
Modify makedoc.pl to remove the N_() tag, and to also note the type as
"string (localized)".
The makedoc.pl already will ignore L10N comment so add a basic comment
above each config var in init.h.
I'm not tagging $crypt_protected_headers_subject because the spec now
says this should be "...". I plan on implementing that change along
with other fixes before the next release.
|
|
|
|
The buffer pool is now used for command invocation, but unfortunately
a couple cases of mutt_buffer_init() were hidden in the my_hdr and
score command processors.
This would result in a shortened buffer being returned to the pool and
used later for something like the prompt - which expects LONG_STRING
everywhere.
Fix up the two places to instead copy the string over. They don't
need to grab a large buffer pool sized hunk of memory.
Also, fix the mutt_buffer_pool_release() to resize upwards in case
future code does this. I should have done this originally, but was
afraid it would paper over more serious issues. :-/
Thanks to Armin Wolfermann for reporting the problem.
|
|
Original Author: Christoph Berg <myon@debian.org>
Use cases are saving attachments to some other place and others.
Modified by Kevin McCarthy:
- Fix up documentation to use cmdsynopsis/command/arg.
- Add muttrc.man entry.
- Fix compilation error.
- Clean up the parse_cd() function to use buffers and remove new
translation strings.
|
|
An initial inline part was previously always skipped, for the good
reasons outlined by @dgc in #217.
Unfortunately, some mail clients have started sending "attachments" as
the root (and only) part, more and more lately. Although this may be
bad practice, Mutt should support counting these as "attachments".
To do so without breaking existing configs, add a "root" disposition
argument to the attachments command. This will count an initial
inline part in a message or multipart container.
The existing code skipped counting for the "top-level" and recursive
calls, so group both of these cases under "root".
|
|
Convert getdnsdomainname(), called by mutt_init(), to accept a BUFFER
parameter instead.
|
|
Fix backtick processing to append to tok instead of allocating and
assigning to tok->data directly.
|
|
Previously, the parameter converted into a kind of read-only buffer,
pointing to the char *line passed in. The problem is that
mutt_extract_token() backtick processing allocates and assigns a new
token->data.
As a result, buffer->destroy was added, whose sole purpose is to keep
track of the read-only token buffer being reallocated so that it can
be properly freed inside mutt_parse_rc_line(). (The char *line is
allocated and freed in source_rc()).
Remove the token parameter, and convert line to a const char *. Copy
that into a buffer-pool buffer, so the buffer can be modified
"normally".
Create a mutt_buffer_rc_buffer() function taking the line buffer
parameter. To make the source_rc() just a tiny bit faster, have it
directly manage and call mutt_parse_rc_buffer() itself.
Other callers likely don't need the speed, so remove their cumbersome
creation/free of that parameter.
The next commit will deal with removing buffer->destroy and fixing up
backtick handling.
|
|
The variable defaults unset, to prevent breaking anyone's
configuration.
If set to a value, such as ",", $record and fcc-hook may list multiple
mailboxes separated by the delimiter. Mutt will tokenize and
expand/prettify each separate mailbox. At Fcc time, it will loop
through trying to save to each mailbox.
This patch introduces a bit more uglyness into init.c, which has to
special-process for $record in a few places. I don't like that, but I
believe the feature is important enough to allow for the one-off
behavior hack, because we are constrained by backwards compatibility.
Add documentation notes about the resulting issues with '<' mailbox
shortcut expansion, and with fcc-save-hook processing. It is
recommended to use fcc-hook to set multiple mailboxes in those cases
instead.
|
|
|
|
|
|
Don't use the buf parameter to avoid stretching it out, as it's used
for the entire rc parsing, and typically just holds command names.
|
|
The * option clears all previous attachments settings. A
list_free_generic method is added to muttlib to enable generic freeing
of specific LIST structures. free_attachments_data is used with
list_free_generic to clear four LISTs which manage allowed and excluded
inline and attached "attachments"
refs #1
|
|
MuttVars of those types are set via safe_strdup(), which returns NULL
if the original is "". Thus Var implies *Var.
A good portion of the code relies on that axiom, but over the years
some (Var && *Var) checks have crept in, including from me.
This was partially because of the INITVAL("") that were in the code,
which implied (incorrectly) the initial value could be "". Commit
2f91d43e removed those to make it more clear.
This commit removes the *Var checks to make it even clearer, and help
avoid them creeping back in again.
|
|
As with MuttVars, Commands was using an unsigned long to hold pointers
as well as enums. Convert to use the same union type of MuttVars.
Adjust command functions data parameter type to the union. Since
these are used outside init.c, relocate the union definition to
mutt.h.
Although the number of functions affected was long, most of them did
not need much adjustment. Many of them made no use of the parameter.
Those that did were easily cast into an added "data" variable at the
top.
|
|
They were using an "unsigned long" and casting to a pointer when
needed. Obviously this has "worked" for a long time, but it's not
correct to assume a pointer can fit in unsigned long.
Replace with a union contain "void *p" and "long l". Fortunately, the
only parts making direct use of MuttVars are in init.h and init.c, so
we just need to update those manipulation functions.
In general I don't like single letter variables, but brevity is worth
it in this case.
|
|
19 years ago, they briefly performed different things, but the
mutt_pretty_mailbox() has been commented out since then.
|
|
Switch to generating the version string during make process rather than
at configure time. This makes it easier to keep the detailed version
string accurate when doing development which doesn't require that the
configure script be rerun.
|
|
Use mutt_buffer_len() and mutt_buffer_clear() to make the code a bit
clearer. There are still places in the code that manipulate the
buffers directly (pattern.c, for example), but that doesn't mean we
shouldn't abstract the buffer where we can.
Add comments in a couple places where unusual buffer manipulation is
occurring.
|
|
Add spaces after if, else, while, for, switch.
Unify the brace placement style. The vast majority of the code uses
Allman style so convert the relatively few K&R braces over.
|
|
These are mostly automated changes corresponding to the emacs
settings:
(c-set-style "linux")
(setq c-basic-offset 2)
(c-set-offset 'case-label '+)
Most of the code follows the convention:
(add-to-list 'c-cleanup-list 'space-before-funcall)
but this is not enforced by this indentation cleanup.
Also, I personally dislike tabs, so I have:
(setq-default indent-tabs-mode nil)
in my own configuration. However I have no desire to change every line
just for that effect. So this cleanup does nothing about the mix issue.
Some of the secondary files (e.g. regex.c) have been skipped.
I've also skipped crypt-gpgme.c, because I need to think about that
file. Werner Koch and the GnuPG team contributed most it, and it
follows the Gnu indentation settings. It should probably be made
uniform with Mutt, but I don't want to discourage future GnuPG
contribution to the file.
I manually reverted a few unsightly cleanups, and added a few tweeks
when I saw things that could be improved.
|
|
The result of
find . -name "*.[ch]" -exec emacs -batch {} \
--eval="(progn (delete-trailing-whitespace) (and (buffer-modified-p) (save-buffer)))" \;
|
|
Most of these have been "#if 0" out for 10-20 years. Any utility in
keeping them around is miniscule at this point.
There are a few other "#if 0" in the code, but I've kept them for now.
Some are utility functions that are not used, but I think still may
have some documentation value.
|
|
|
|
When set, it automatically subscribes to mailing lists found in
List-Post headers.
This commit is based on Michael Elkins's patch from the thread
<https://marc.info/?l=mutt-users&m=127076105423565&w=2>.
I've added an opt-in variable $auto_subscribe and a hash table cache
to speed up reading headers when the variable is set.
|
|
|
|
Mutt relies on it being a single character set, but failed to make
sure of that in check_charset().
Thanks to Hans-Peter Jansen for reporting the problem, and to Mel
Gorman for working with me to track down the issue in his
configuration.
|
|
index-format-hook is used to allow dynamic insertion/evaluation of
format strings into $index_format.
It can be used, for example, to implement date formatting based on the
age of the message.
Add a new %@name@ expando to $index_format, which evaluates the
matching index-format-hooks with "name".
|
|
Also add a few helper functions: mutt_buffer_clear(),
mutt_buffer_strcpy(), and a macro mutt_b2s to grab the buffer data as
a const char *.
|
|
This came up in the comp.mail.mutt newsgroup where a user wasn't
satisfied with the SHORT_MAX seconds ~9 hours limit on passphrase
timeouts.
For the first time made it necessary for the options parser to be
able to parse numbers as long values. Also, introduced
mutt_add_timeout() to detect possible overflow before adding a
timeout to a time_t value and truncate to TIME_T_MAX instead.
|
|
|