commit 0edb606e0f07aed3552375c9380ccf2fe3e6ba99 Author: Oswald Buddenhagen <o...@users.sf.net> Date: Mon Mar 10 11:57:22 2014 +0100
don't needlessly quote strings src/compat/config.c | 28 ++++++++++++++++++++++------ 1 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/compat/config.c b/src/compat/config.c index ee15305..2e160b6 100644 --- a/src/compat/config.c +++ b/src/compat/config.c @@ -27,6 +27,7 @@ #include <string.h> #include <stdlib.h> #include <stdio.h> +#include <ctype.h> static int local_home, local_root; @@ -234,6 +235,21 @@ tb( int on ) return on ? "yes" : "no"; } +static const char * +quotify( const char *str ) +{ + char *ostr; + int i; + + for (i = 0; str[i]; i++) { + if (isspace( str[i] )) { + nfasprintf( &ostr, "\"%s\"", str ); + return ostr; + } + } + return str; +} + static void write_imap_server( FILE *fp, config_t *cfg ) { @@ -304,16 +320,16 @@ write_imap_server( FILE *fp, config_t *cfg ) fprintf( fp, "Port %d\n", cfg->port ); } if (cfg->user) - fprintf( fp, "User \"%s\"\n", cfg->user ); + fprintf( fp, "User %s\n", quotify( cfg->user ) ); if (cfg->pass) - fprintf( fp, "Pass \"%s\"\n", cfg->pass ); + fprintf( fp, "Pass %s\n", quotify( cfg->pass ) ); fprintf( fp, "RequireCRAM %s\nRequireSSL %s\n" "UseSSLv2 %s\nUseSSLv3 %s\nUseTLSv1 %s\n", tb(cfg->require_cram), tb(cfg->require_ssl), tb(cfg->use_sslv2), tb(cfg->use_sslv3), tb(cfg->use_tlsv1) ); if ((cfg->use_imaps || cfg->use_sslv2 || cfg->use_sslv3 || cfg->use_tlsv1) && cfg->cert_file) - fprintf( fp, "CertificateFile %s\n", cfg->cert_file ); + fprintf( fp, "CertificateFile %s\n", quotify( cfg->cert_file ) ); fputc( '\n', fp ); } @@ -327,13 +343,13 @@ write_imap_store( FILE *fp, config_t *cfg ) fprintf( fp, "IMAPStore %s\nAccount %s\n", cfg->store_name, cfg->server_name ); if (*folder) - fprintf( fp, "Path \"%s\"\n", folder ); + fprintf( fp, "Path %s\n", quotify( folder ) ); else fprintf( fp, "UseNamespace %s\n", tb(cfg->use_namespace) ); if (inbox) - fprintf( fp, "MapInbox \"%s\"\n", inbox ); + fprintf( fp, "MapInbox %s\n", quotify( inbox ) ); if (cfg->copy_deleted_to) - fprintf( fp, "Trash \"%s\"\n", cfg->copy_deleted_to ); + fprintf( fp, "Trash %s\n", quotify( cfg->copy_deleted_to ) ); fputc( '\n', fp ); } ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel