Re: [PATCH] Improve UI consistency

2017-06-06 Thread Tamo
On Tue, Jun 6, 2017 at 12:11 PM, Kevin J. McCarthy  wrote:
> On Mon, Jun 05, 2017 at 02:14:11PM +0300, Consus wrote:
>> On 14:46 Fri 02 Jun, Kevin J. McCarthy wrote:
>> > Thanks for the patch!  Normally I don't touch the .po files, but in this
>> > case I understand why you did.
>> >
>> > The change makes sense to me, but sometimes it's the tiniest things that
>> > cause the most controversy.  So I'm going to give this a couple days
>> > just to make sure everyone sees it first.
>>
>> Sounds good to me.
>
> I was working on pushing this, when I realized there already is a "Sign
> as: " in the translation files.
>
> At first I thought just to strip out the po files from the patch and
> apply.  However, it turns out there is a spacing difference between the
> two for some translations, because of the different uses.
>
> For the lower case version, the translators are manually aligning by
> left padding, and for ja.po, for example, they use a more abbreviated
> version to fit in the compose menu better.

At least for ja.po, the proposed change is not a big problem.
The shorter message (for compose.c) is not too abbreviated.
It can be used also in crypto functions.
So I am not against the change if the other translators are ok.

-- 
Tamo


Re: corrupted attachments

2017-06-06 Thread Andras Salamon

On 2017-06-06 01:34:37 +0200, Andries E. Brouwer wrote:

It is also very easy to check for well-formed UTF-8. Well-formed UTF-8
with short lines should perhaps be classified as "text".


As a UTF-8 zealot, I would like to see this stricter heuristic being
applied, with all other files attached without text interpretation.
Rejecting any invalid UTF-8 by applying RFC 3629 strictly would be
reasonable for this use case.  It would also be reasonable to follow
file/libmagic's stance in file_looks_utf8() (at least in file-4.26 and
later) and conclude that any "odd" control characters are enough to
disqualify the file from being text.
   ftp://ftp.astron.com/pub/file/

The (hibin+ascii)/lobin >= 9 hack that has been in the code since at
least 2002 needs to go.  The question is what to do with a text file
that is correctly encoded for its locale, but that fails to be valid
UTF-8.  Even a Windows-125[0-8] or GB2312 encoded text file that is not
valid UTF-8 is "clearly" binary to me, but there are probably many mutt
users who would object to such semantics.  A general solution would be
to determine the semantics of "text" depending on locale, or to use a
conservative heuristic but allow this to be overridden as an option.

-- Andras Salamon   and...@dns.net


Re: [PATCH] Improve UI consistency

2017-06-06 Thread Vincent Lefevre
On 2017-06-05 20:11:41 -0700, Kevin J. McCarthy wrote:
> For the lower case version, the translators are manually aligning by
> left padding, and for ja.po, for example, they use a more abbreviated
> version to fit in the compose menu better.

IMHO, it is wrong to add spaces in the translation. This can
obviously yield inconsistencies when the same source string is
used several times. If alignment may be needed, this should be
handled by the source.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Re: corrupted attachments

2017-06-06 Thread Vincent Lefevre
On 2017-06-06 01:34:37 +0200, Andries E. Brouwer wrote:
> On Mon, Jun 05, 2017 at 03:35:28PM -0700, Kevin J. McCarthy wrote:
> > This patch considers 8-bit characters as binary for the calculation.  In
> > general, it's probably better to guess wrong on the conservative side
> > than possibly corrupt attachments.
> 
> > -if (info->lobin == 0 || (info->lobin + info->hibin + info->ascii)/ 
> > info->lobin >= 10)
> > +if ((info->lobin == 0 && info->hibin == 0) ||
> > +(info->lobin + info->hibin + info->ascii) / (info->lobin + 
> > info->hibin) >= 10)
> 
> Yes, this fixes my problem.
> On the other hand, some simple UTF-8 text files are now also treated
> as binary.

This is what I feared just after seeing this patch. This is really
bad, in particular because text/plain files often don't have an
extension, contrary to binary files (well, executables don't have
an extension, but one normally don't send executables by e-mail as
attachments).

> It is also very easy to check for well-formed UTF-8. Well-formed UTF-8
> with short lines should perhaps be classified as "text".

Yes, and even with long lines. IMHO, this would be safe in practice.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Re: [PATCH] Improve UI consistency

2017-06-06 Thread Kevin J. McCarthy
On Tue, Jun 06, 2017 at 03:50:06PM +0200, Vincent Lefevre wrote:
> On 2017-06-05 20:11:41 -0700, Kevin J. McCarthy wrote:
> > For the lower case version, the translators are manually aligning by
> > left padding, and for ja.po, for example, they use a more abbreviated
> > version to fit in the compose menu better.
> 
> IMHO, it is wrong to add spaces in the translation. This can
> obviously yield inconsistencies when the same source string is
> used several times. If alignment may be needed, this should be
> handled by the source.

I agree.  Mutt should be doing better alignment for multibyte
characters.  I'll look into this soon, and will commit the "Sign as:"
change when that is working better.

-- 
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA


signature.asc
Description: PGP signature


mutt: 3 new changesets

2017-06-06 Thread Brendan Cully
changeset: 7078:915ba3928d49
user:  Kevin McCarthy 
date:  Tue Jun 06 18:38:41 2017 -0700
link:  http://dev.mutt.org/hg/mutt/rev/915ba3928d49

Restore setenv function.

Partially revert fa1192803257, restoring setenv.  It turns out we
still need the function.

changeset: 7079:02ff4277259e
user:  Kevin McCarthy 
date:  Tue Jun 06 18:38:46 2017 -0700
link:  http://dev.mutt.org/hg/mutt/rev/02ff4277259e

Move setting of GPG_TTY to mutt_init(). (see #3948)

This allows other programs mutt runs to use the ncurses pinentry if needed.

changeset: 7080:cf90bf5989f3
user:  Kevin McCarthy 
date:  Tue Jun 06 18:38:47 2017 -0700
link:  http://dev.mutt.org/hg/mutt/rev/cf90bf5989f3

Add a mutt_endwin() before invoking $sendmail. (closes #3948)

This is to support invoking a program such as msmtp that can use gpg
to decrypt a password.  The ncurses pinentry can corrupt the screen
unless we exit curses.

diffs (157 lines):

diff -r a11770c2137b -r cf90bf5989f3 configure.ac
--- a/configure.ac  Fri Jun 02 13:17:40 2017 -0700
+++ b/configure.ac  Tue Jun 06 18:38:47 2017 -0700
@@ -374,7 +374,7 @@
 
 AC_CHECK_FUNCS(fgetpos memmove setegid srand48 strerror)
 
-AC_REPLACE_FUNCS([strcasecmp strdup strsep strtok_r wcscasecmp])
+AC_REPLACE_FUNCS([setenv strcasecmp strdup strsep strtok_r wcscasecmp])
 AC_REPLACE_FUNCS([strcasestr mkdtemp])
 
 AC_CHECK_FUNC(getopt)
diff -r a11770c2137b -r cf90bf5989f3 init.c
--- a/init.cFri Jun 02 13:17:40 2017 -0700
+++ b/init.cTue Jun 06 18:38:47 2017 -0700
@@ -3317,6 +3317,7 @@
   char *domain = NULL;
   int i, need_pause = 0;
   BUFFER err;
+  char *tty;
 
   mutt_buffer_init (&err);
   err.dsize = STRING;
@@ -3510,6 +3511,20 @@
 unset_option (OPTSUSPEND);
 #endif
 
+  /* GPG_TTY is used by the ncurses pinentry program for GPG.  GPG is
+   * sometimes also used to decrypt passwords in programs launched by
+   * mutt, such as using msmtp as $sendmail, so we set it here as
+   * opposed to inside pgp.c
+   *
+   * We also call setenv() because send_msg() is not converted to use
+   * the mutt envlist.
+   */
+  if ((tty = ttyname(0)))
+  {
+setenv("GPG_TTY", tty, 0);
+mutt_envlist_set ("GPG_TTY", tty, 0);
+  }
+
   mutt_init_history ();
 
   /* RFC2368, "4. Unsafe headers"
diff -r a11770c2137b -r cf90bf5989f3 m4/gettext.m4
--- a/m4/gettext.m4 Fri Jun 02 13:17:40 2017 -0700
+++ b/m4/gettext.m4 Tue Jun 06 18:38:47 2017 -0700
@@ -318,7 +318,7 @@
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
 stdlib.h string.h unistd.h sys/param.h])
AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
-getgid getuid mempcpy munmap putenv setlocale stpcpy strchr strcasecmp \
+getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
 strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
 
MUTT_AM_ICONV
diff -r a11770c2137b -r cf90bf5989f3 pgp.c
--- a/pgp.c Fri Jun 02 13:17:40 2017 -0700
+++ b/pgp.c Tue Jun 06 18:38:47 2017 -0700
@@ -105,18 +105,13 @@
   mutt_message _("PGP passphrase forgotten.");
 }
 
+/* This function used to do more: check GPG_AGENT_INFO,
+ * set GPG_TTY.  GPG_AGENT_INFO is no longer exported, and GPG_TTY
+ * is now set in mutt_init().
+ */
 int pgp_use_gpg_agent (void)
 {
-  char *tty;
-
-  /* GnuPG 2.1 no longer exports GPG_AGENT_INFO */
-  if (!option (OPTUSEGPGAGENT))
-return 0;
-
-  if ((tty = ttyname(0)))
-mutt_envlist_set ("GPG_TTY", tty, 0);
-
-  return 1;
+  return option (OPTUSEGPGAGENT);
 }
 
 static pgp_key_t _pgp_parent(pgp_key_t k)
diff -r a11770c2137b -r cf90bf5989f3 protos.h
--- a/protos.h  Fri Jun 02 13:17:40 2017 -0700
+++ b/protos.h  Tue Jun 06 18:38:47 2017 -0700
@@ -543,6 +543,10 @@
 
 /* prototypes for compatibility functions */
 
+#ifndef HAVE_SETENV
+int setenv (const char *, const char *, int);
+#endif
+
 #ifndef HAVE_STRCASECMP
 int strcasecmp (char *, char *);
 int strncasecmp (char *, char *, size_t);
diff -r a11770c2137b -r cf90bf5989f3 sendlib.c
--- a/sendlib.c Fri Jun 02 13:17:40 2017 -0700
+++ b/sendlib.c Tue Jun 06 18:38:47 2017 -0700
@@ -2446,6 +2446,7 @@
 
   args[argslen++] = NULL;
 
+  mutt_endwin (NULL);
   if ((i = send_msg (path, args, msg, option(OPTNOCURSES) ? NULL : &childout)) 
!= (EX_OK & 0xff))
   {
 if (i != S_BKG)
diff -r a11770c2137b -r cf90bf5989f3 setenv.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/setenv.c  Tue Jun 06 18:38:47 2017 -0700
@@ -0,0 +1,45 @@
+/*  Replacement for a missing setenv.
+**
+**  Written by Russ Allbery 
+**  This work is hereby placed in the public domain by its author.
+**
+**  Provides the same functionality as the standard library routine setenv
+**  for those platforms that don't have it.
+*/
+
+#include "config.h"
+
+#include 
+#include 
+
+int
+setenv(const char *name, const char *value, int overwrite)
+{
+char *envstring;
+
+if (!overwrite && getenv(name) != NULL)
+return 0;
+
+/* Allocate memory for the enviro

Re: [Mutt] #3948: Please add a hook called just before sendmail invocation

2017-06-06 Thread Mutt
#3948: Please add a hook called just before sendmail invocation
--+--
  Reporter:  tpikonen |  Owner:  mutt-dev
  Type:  enhancement  | Status:  closed
  Priority:  minor|  Milestone:
 Component:  mutt |Version:
Resolution:  fixed|   Keywords:
--+--
Changes (by Kevin McCarthy ):

 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"cf90bf5989f357e115c8aa2763d4e3185e8766e9"
 7080:cf90bf5989f3]:
 {{{
 #!CommitTicketReference repository=""
 revision="cf90bf5989f357e115c8aa2763d4e3185e8766e9"
 Add a mutt_endwin() before invoking $sendmail. (closes #3948)

 This is to support invoking a program such as msmtp that can use gpg
 to decrypt a password.  The ncurses pinentry can corrupt the screen
 unless we exit curses.
 }}}

--
Ticket URL: 
Mutt 
The Mutt mail user agent



Re: [Mutt] #3948: Please add a hook called just before sendmail invocation

2017-06-06 Thread Mutt
#3948: Please add a hook called just before sendmail invocation
--+--
  Reporter:  tpikonen |  Owner:  mutt-dev
  Type:  enhancement  | Status:  new
  Priority:  minor|  Milestone:
 Component:  mutt |Version:
Resolution:   |   Keywords:
--+--

Comment (by Kevin McCarthy ):

 In [changeset:"02ff4277259e5298ae9ba7f4f45c0f972f22e11c"
 7079:02ff4277259e]:
 {{{
 #!CommitTicketReference repository=""
 revision="02ff4277259e5298ae9ba7f4f45c0f972f22e11c"
 Move setting of GPG_TTY to mutt_init(). (see #3948)

 This allows other programs mutt runs to use the ncurses pinentry if
 needed.
 }}}

--
Ticket URL: 
Mutt 
The Mutt mail user agent