All of lore.kernel.org
 help / color / mirror / Atom feed
* imap.preformattedHTML and imap.sslverify
@ 2010-02-06 19:26 Junio C Hamano
  2010-02-08 22:31 ` Jeremy White
  0 siblings, 1 reply; 49+ messages in thread
From: Junio C Hamano @ 2010-02-06 19:26 UTC (permalink / raw)
  To: git; +Cc: Jeremy White, Robert Shearman

I hate to bring up a topic that is almost a year old, but has either of
these configuration variables ever worked?

The code does this while reading its configuration file:

        static int git_imap_config(const char *key, const char *val, void *cb)
        {
                char imap_key[] = "imap.";

                if (strncmp(key, imap_key, sizeof imap_key - 1))
                        return 0;

                if (!val)
                        return config_error_nonbool(key);
                ...
                else if (!strcmp("sslverify", key))
                        server.ssl_verify = git_config_bool(key, val);
                else if (!strcmp("preformattedHTML", key))
                        server.use_html = git_config_bool(key, val);

Two issues:

 - The body of the function is protected by "nonbool" written back in the
   days when there was no boolean variables in imap.* namespace.  Hence,
   a user cannot write

           [imap]
                sslverify

   and turn it on.  The user needs to write


           [imap]
                sslverify = True

   which is against the parsing rules for boolean variables.

 - The config parser downcases the key before calling the parse callback
   function, so !strcmp("preformattedHTML", key) will never trigger.

The fix is obvious (see below), but I am far more disturbed by the
apparent lack of testing.  Especially, preformattedHTML one would have
never worked as setting the configuration is the only way to trigger this.

Could peole _test_ this patch and report, as I don't use this program at
all.

Thanks.

 imap-send.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/imap-send.c b/imap-send.c
index de8114b..ea769a9 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1335,11 +1335,16 @@ static int git_imap_config(const char *key, const char *val, void *cb)
 	if (strncmp(key, imap_key, sizeof imap_key - 1))
 		return 0;
 
-	if (!val)
-		return config_error_nonbool(key);
-
 	key += sizeof imap_key - 1;
 
+	/* check booleans first, and barf on others */
+	if (!strcmp("sslverify", key))
+		server.ssl_verify = git_config_bool(key, val);
+	else if (!strcmp("preformattedhtml", key))
+		server.use_html = git_config_bool(key, val);
+	else if (!val)
+		return config_error_nonbool(key);
+
 	if (!strcmp("folder", key)) {
 		imap_folder = xstrdup(val);
 	} else if (!strcmp("host", key)) {
@@ -1360,10 +1365,6 @@ static int git_imap_config(const char *key, const char *val, void *cb)
 		server.port = git_config_int(key, val);
 	else if (!strcmp("tunnel", key))
 		server.tunnel = xstrdup(val);
-	else if (!strcmp("sslverify", key))
-		server.ssl_verify = git_config_bool(key, val);
-	else if (!strcmp("preformattedHTML", key))
-		server.use_html = git_config_bool(key, val);
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2010-02-18 15:45 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-06 19:26 imap.preformattedHTML and imap.sslverify Junio C Hamano
2010-02-08 22:31 ` Jeremy White
2010-02-08 23:05   ` Junio C Hamano
2010-02-09 12:09     ` [PATCH 0/4] Some improvements for git-imap-send Hitoshi Mitake
2010-02-09 15:06       ` Jeff King
2010-02-09 15:13         ` Erik Faye-Lund
2010-02-09 16:57           ` Jeff King
2010-02-09 18:37             ` Erik Faye-Lund
2010-02-09 18:54               ` Jeff King
2010-02-11 14:38       ` [PATCH v2 1/2] git-imap-send: Add CRAM-MD5 authenticate method support Hitoshi Mitake
2010-02-11 14:55         ` Erik Faye-Lund
2010-02-11 14:59           ` Hitoshi Mitake
2010-02-11 15:06           ` [PATCH v3 " Hitoshi Mitake
2010-02-11 20:30             ` Junio C Hamano
2010-02-12 11:23               ` Hitoshi Mitake
2010-02-11 14:38       ` [PATCH v2 2/2] git-imap-send: Convert LF to CRLF before storing patch to draft box Hitoshi Mitake
2010-02-11 20:48         ` Junio C Hamano
2010-02-12 11:24           ` Hitoshi Mitake
2010-02-11 14:45       ` [PATCH v2 1/2] git-imap-send: Add CRAM-MD5 authenticate method support Hitoshi Mitake
2010-02-11 14:45       ` [PATCH v2 2/2] git-imap-send: Convert LF to CRLF before storing patch to draft box Hitoshi Mitake
2010-02-12 11:36       ` [PATCH v4 1/2] git-imap-send: Add CRAM-MD5 authenticate method support Hitoshi Mitake
2010-02-12 12:41         ` Erik Faye-Lund
2010-02-13  4:21           ` Hitoshi Mitake
2010-02-12 21:44         ` Junio C Hamano
2010-02-13  6:49           ` Hitoshi Mitake
2010-02-13  6:56             ` [PATCH v5 " Hitoshi Mitake
2010-02-13  7:42             ` [PATCH v4 " Junio C Hamano
2010-02-16  6:34               ` Junio C Hamano
2010-02-17  9:17                 ` Hitoshi Mitake
2010-02-17  9:18                   ` [PATCH v6 " Hitoshi Mitake
2010-02-17 18:31                   ` [PATCH v4 " Junio C Hamano
2010-02-18 15:45                     ` Hitoshi Mitake
2010-02-17  8:51               ` Hitoshi Mitake
2010-02-12 11:36       ` [PATCH v4 2/2] git-imap-send: Convert LF to CRLF before storing patch to draft box Hitoshi Mitake
2010-02-09 12:09     ` [PATCH 1/4] Add base64 encoder and decoder Hitoshi Mitake
2010-02-09 14:45       ` Erik Faye-Lund
2010-02-11 14:37         ` Hitoshi Mitake
2010-02-09 12:09     ` [PATCH 2/4] Add stuffs for MD5 hash algorithm Hitoshi Mitake
2010-02-09 12:09     ` [PATCH 3/4] git-imap-send: Implement CRAM-MD5 auth method Hitoshi Mitake
2010-02-09 14:22       ` Erik Faye-Lund
2010-02-11 14:55         ` Hitoshi Mitake
2010-02-11 14:59           ` Erik Faye-Lund
2010-02-11 15:11             ` Hitoshi Mitake
2010-02-09 12:09     ` [PATCH 4/4] git-imap-send: Add method to convert from LF to CRLF Hitoshi Mitake
2010-02-09 16:15       ` Jakub Narebski
2010-02-11 14:37         ` Hitoshi Mitake
2010-02-09 17:24       ` Linus Torvalds
2010-02-09 18:20         ` Junio C Hamano
2010-02-11 14:38           ` Hitoshi Mitake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.