Richard Russon [Wed, 2 Dec 2015 03:58:44 +0000 (03:58 +0000)]
build: conditional compilation
Make sidebar compilation conditional on a configure option.
Add --enable-sidebar option to configure
Alter Makefile to honour configure
Move our OPS into OPS.sidebar
Surround all our code with #ifdef USE_SIDEBAR
By using the unifdef program, all the sidebar code can be removed.
The result is code that differs only slightly from the original mutt
code. Run this on each source file:
Compared to the original mutt code, there are some minor changes,
such as whitespace, and minor refactoring of variables.
Note: One sidebar global variable is left-behind: SidebarWidth.
This is deeply embedded in the mutt code. This is because mutt
hard-codes a lot of values: 0's for the left-hand side of the
screen and COLS representing the width of the screen.
Richard Russon [Wed, 2 Dec 2015 03:58:15 +0000 (03:58 +0000)]
tidy: add comments
NOTE: this patch does NOT make any code changes.
It simply adds comment blocks.
Fully document all the sidebar config options.
Add comment-blocks describing each function -- what it does, the
parameters it takes, the return values. These can be used by
doxygen.
Richard Russon [Wed, 2 Dec 2015 03:03:49 +0000 (03:03 +0000)]
tidy: sidebar
Tidy up code in sidebar.c
Minor refactoring of code
Initialise variables
Check pointers before use
Bracket complicated logic
Add {} to unbalanced, or ambiguous, if's
Align = signs
Split up illegible uses of ternary operator ? :
Split up: if ((x = y()) == NULL)
Remove perl-like one-line if's
Compare pointers to NULL
Move our private data struct (sidebar_entry) from protos.h
Richard Russon [Mon, 30 Nov 2015 16:37:36 +0000 (16:37 +0000)]
fix: drop DrawFullLine
Drop global variable DrawFullLine
sidebar used a global variable in order to occasionally draw a
complete line of text on the screen. By manipulating the
SidebarWidth, we can produce the same effect.
Removing this variable also removes the need for nearly 50 lines of
duplicated code in mutt_FormatString.
Richard Russon [Tue, 1 Dec 2015 04:14:25 +0000 (04:14 +0000)]
fix: drop unused
NOTE: this patch does NOT make any functional changes.
remove unused parameters from:
draw_sidebar
scroll_sidebar
calc_boundaries
draw_sidebar has a return value that isn't used
struct MBOX_LIST isn't used
remove some unneeded #include's
remove defunct #ifdef BUFFY_SIZE
remove junk comments
Richard Russon [Tue, 24 Nov 2015 16:27:20 +0000 (16:27 +0000)]
feature: working utf8
Correctly handle utf8 character sequences.
Fix the distinction, in the code, between buffer length in bytes,
string length in wide-chars and screen width in cells.
Steve Kemp [Thu, 19 Nov 2015 18:29:49 +0000 (18:29 +0000)]
feature: new only
Add new config: "sidebar_newmail_only"
Only display mailboxes containing new mail.
Add two new functions and keyboard mappings.
"sidebar-next-new" / "sidebar-prev-new" select the next/previous
mailbox that contains new, or flagged, mail.
Official Mutt-Sidebar patch against mutt-1.5.24
http://www.lunar-linux.org/mutt-sidebar/
http://lunar-linux.org/~tchan/mutt/patch-1.5.24.sidebar.20151111.txt
Kevin McCarthy [Fri, 1 Apr 2016 16:38:47 +0000 (09:38 -0700)]
Fix hcversion.h generation error when using included gettext.
When configuring mutt with --enable-hcache and
--with-included-gettext, there is an automake ordering issue:
BUILT_SOURCES are processed before SUBDIRS. Therefore, the
'hcversion.h' target is run before the included gettext (intl) is
built.
The hcversion.h target runs the cpp over config.h and mutt.h,
but mutt.h includes lib.h which tries to #include <libintl.h>.
Unfortunately, libintl.h (in this configuration) is generated by the
intl subdir build and so doesn't exist yet.
While the build doesn't completely fail, the resulting hcversion.h is
incorrect: it's just the md5sum of the initial value of BASEVERSION.
This fix is somewhat of a hack but is cleaner than trying to change
automake's behavior. It inserts a '#undef ENABLE_NLS' in between the
config.h and mutt.h sent to the cpp. Since hcachever.sh is just
scanning the data structures used by mutt, this shouldn't affect the
hash generated.
Kevin McCarthy [Wed, 30 Mar 2016 20:16:20 +0000 (13:16 -0700)]
Filter out bidi marks in rfc2047 and rfc2231 encoding. (see #3827)
Filter out U+200F RIGHT-TO-LEFT MARK and U+200E LEFT-TO-RIGHT MARK in
rfc2047 and 2231 encoded fields. GNU Screen has a bug that corrupts
the display, and can cause the wrong email to appear to be selected in
the index. Until screen fixes the issue, filter it out in mutt.
Kevin McCarthy [Sat, 26 Mar 2016 22:45:18 +0000 (15:45 -0700)]
Fix error handling in sync_helper() and imap_sync_mailbox(). (closes #3817)
This patch is based on the one Richard Russon found in the Fedora package.
If an error occurs during one of the imap_exec() calls in
imap_sync_mailbox(), the mailbox could end up being closed. This
would cause idata->ctx to be NULL. Add a check in sync_helper() for
the case where idata->ctx == NULL.
In imap_sync_mailbox(), check the return value of sync_helper(). To
keep the code simple, change rc from being the sum of the calls to the
bitwise-OR of the calls. (We only need to know if a single flag needs
to be updated, and bitwise-OR will detect negatives.)
Below the calls to sync_helper(), if the call to imap_exec() fails,
make sure rc is set to -1.
Kevin McCarthy [Wed, 23 Mar 2016 22:28:25 +0000 (15:28 -0700)]
Prevent renaming root folder in imap.
The root folder results in mx.mbox being NULL, which causes a
segfault. This can be triggered by entering a subfolder and trying to
rename the ".." entry.
Due to the translation string freeze, no visible error message is
displayed. Add a TODO note about this for post-1.6 release.
Kevin McCarthy [Wed, 23 Mar 2016 01:00:13 +0000 (18:00 -0700)]
Clean up mutt_wstr_trunc() some more.
* Change return type to size_t.
The return value is the cumulation of values from mbrtowc(), which
returns size_t. All callers already assign the return value to a
size_t, requiring no external changes.
* Change the local variables n, w, l, and cl to size_t.
n is the strlen of the src parameter. l and cl are used for the
return value. w is assigned to the *width parameter, which is
size_t.
cw is kept as an int, because wcwidth returns type int.
* Change error handling of mbrtowc to be the same as other functions
in mutt: only reset mbstate when the retval==-1. When retvat==-2,
set cl=n to break out of the loop. Also, set wc to replacement_char
and allow the logic below to determine the width instead of
hardcoding to 1.
Kevin McCarthy [Sun, 20 Mar 2016 00:25:10 +0000 (17:25 -0700)]
Turn off asserts in sendlib.c.
The Doctor reported triggering an assertion in convert_file_to(), due
to an unexpected errno from iconv(). According to the comments, the
assertions were only enabled for debugging and should have been turned
off. We certainly don't want to abort mutt for this case, so just
disable them as the comment indicates.
Kevin McCarthy [Wed, 16 Mar 2016 01:04:26 +0000 (18:04 -0700)]
Prevent ctx->fp from being closed twice in the event of an error.
The previous patch from Vincent exposed a crash if ftruncate() fails
in mbox_sync_mailbox(). Change fclose() to safe_fclose(), to avoid it
being called twice.
The function generating a list of parts to join had incorrect sorting
logic. It was comparing values, not attributes. Additionally, the
order logic wasn't correct.
Thanks to TAKAHASHI Tamotsu for pointing out the value vs attribute
comparison bug.
Kevin McCarthy [Tue, 8 Mar 2016 23:57:55 +0000 (15:57 -0800)]
Add $resume_edited_draft_files option.
This adds an extra header when saving edited draft files (-E -H on the
command line). With this header, the next time they are edited, they
are automatically "resumed" (by setting $resume_draft_files).
The idea is to prevent multiple user-defined headers and signatures
from being added to the draft message by avoiding processing it as a
brand new message after the first time.
Kevin McCarthy [Tue, 8 Mar 2016 23:57:50 +0000 (15:57 -0800)]
Add $resume_draft_files option.
When set, draft files are processed the same as when resuming
postponed messages. One use of this option is to avoid multiple
user-defined headers and signatures being added to the message.
(e.g. when -E is used repeatedly on the draft files).
Kevin McCarthy [Wed, 2 Mar 2016 23:08:49 +0000 (15:08 -0800)]
Add hard redraw for the gpgme application/pgp handler.
Will Yardley reported display artifacts and keyboard issues after
decrypting a traditional pgp message using gpgme. It turns out the
gpgpme code path was missing a hard_redraw() to repaint the screen
after pinentry.
Kevin McCarthy [Tue, 16 Feb 2016 03:44:23 +0000 (19:44 -0800)]
Add $pgp_decryption_okay to verify multipart/encrypted are actually encrypted. (closes #3770)
In pgp classic mode, if the $pgp_decrypt_command generated output, it
assumed the content was encrypted. However, gpg will generate output
even if the block is simply signed and armored text. The problem is
that mutt was then printing mime headers labelling the output as
encrypted text in the ui.
Add a new option, and suggested value of:
set pgp_decryption_okay="^\\[GNUPG:\\] DECRYPTION_OKAY"
If set, the output from the decrypt command will be scanned for this
regexp to confirm an actual decryption occurred.
Note that gpgme already correctly rejects this form of spoofed message.
Kevin McCarthy [Sun, 7 Feb 2016 18:15:27 +0000 (10:15 -0800)]
Fix pgp and smime decryption in mutt_prepare_template().
Change the "combined" multipart decryption block to only work for pgp,
since mutt_is_multipart_encrypted() currently only checks for pgp
headers and it therefore only worked for pgp in the first place.
Fix the newhdr->security to be based on what that function returns,
instead of the "context" hdr passed in.
Add a smime decryption block below when iterating through the content.
Fix the application/pgp decryption block to assign to hdr->security
using the type of the app/pgp part instead of hdr->content.