X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=filter.c;h=5fdec626f45954e0d364e085c1a9337db0641feb;hb=4d2aca39cdd96958b3f0bbc6973f15aac5133cdc;hp=b9f5963c42c73089a1e13ecaff182859581c743b;hpb=a31d028fde7c44fb8d8011da48d8e417540556ea;p=pkg%2Fabook.git diff --git a/filter.c b/filter.c index b9f5963..5fdec62 100644 --- a/filter.c +++ b/filter.c @@ -140,7 +140,7 @@ get_real_name() pwent = getpwnam(username); - if( (tmp = (char *)malloc(strlen(pwent->pw_gecos) +1)) == NULL) + if((tmp = strdup(pwent->pw_gecos)) == NULL) return strdup(username); rtn = sscanf(pwent->pw_gecos, "%[^,]", tmp); @@ -490,7 +490,7 @@ ldif_read_line(FILE *in) } if(*line != ' ') { - fseek(in, pos, SEEK_SET); + fseek(in, pos, SEEK_SET); /* fixme ! */ free(line); break; } @@ -640,15 +640,15 @@ mutt_read_line(FILE *in, char **alias, char **rest) while( ! ISSPACE(*ptr) ) ptr++; - if( (*alias = (char *)malloc(ptr-tmp+1)) == NULL) { + if( (*alias = (char *)malloc(ptr - tmp)) == NULL) { free(line); return 1; } - strncpy(*alias, tmp, ptr-tmp); + strncpy(*alias, tmp, ptr - tmp - 1); *(*alias + (ptr - tmp)) = 0; - while( ISSPACE(*ptr) ) + while(ISSPACE(*ptr)) ptr++; *rest = strdup(ptr); @@ -657,14 +657,38 @@ mutt_read_line(FILE *in, char **alias, char **rest) return 0; } +static void +mutt_fix_quoting(char *p) +{ + char *escape = 0; + + for(; *p; p++) { + switch(*p) { + case '\"': + if(escape) + *escape = ' '; + break; + case '\\': + escape = p; + break; + default: + escape = 0; + } + } +} + static void mutt_parse_email(list_item item) { char *line = item[NAME]; - char *start = line, *tmp; + char *tmp; char *name, *email; +#if 0 + char *start = line; int i = 0; +#endif + mutt_fix_quoting(line); tmp = strconcat("From: ", line, NULL); getname(tmp, &name, &email); free(tmp); @@ -678,6 +702,10 @@ mutt_parse_email(list_item item) else return; + /* + * this is completely broken + */ +#if 0 while( (start = strchr(start, ',')) && i++ < MAX_EMAILS - 1) { tmp = strconcat("From: ", ++start, NULL); getname(tmp, &name, &email); @@ -693,6 +721,7 @@ mutt_parse_email(list_item item) } } } +#endif } static int @@ -856,6 +885,8 @@ html_export_write_tail(FILE *out) * pine addressbook import filter */ +#define PINE_BUF_SIZE 2048 + static void pine_fixbuf(char *buf) { @@ -894,7 +925,7 @@ pine_parse_buf(char *buf) list_item item; char *start = buf; char *end; - char tmp[400]; + char tmp[PINE_BUF_SIZE]; int i, len, last; int pine_conv_table[]= {NICK, NAME, EMAIL, -1, NOTES}; @@ -905,13 +936,14 @@ pine_parse_buf(char *buf) last=1; len = last ? strlen(start) : (int) (end-start); - len = min(len, 400-1); + len = min(len, PINE_BUF_SIZE - 1); if(i < (int)(sizeof(pine_conv_table) / sizeof(*pine_conv_table)) && pine_conv_table[i] >= 0) { strncpy(tmp, start, len); tmp[len] = 0; - item[pine_conv_table[i]] = strdup(tmp); + if(*tmp) + item[pine_conv_table[i]] = strdup(tmp); } start = end + 1; } @@ -1510,7 +1542,7 @@ text_export_database(FILE * out, struct db_enumerator e) fprintf(out, "-----------------------------------------\n\n"); fprintf(out, "%s", database[e.item][NAME]); - if (database[e.item][NICK]) + if (database[e.item][NICK] && *database[e.item][NICK]) fprintf(out, "\n(%s)", database[e.item][NICK]); fprintf(out, "\n");