X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Finternet_addressing.c;h=57c55b03dfe1f39719e04377273e0fc5edc6ba66;hb=68c5cc783b518571f3ab1d25179a1bcf7015a7ce;hp=afa637a9ad009d33e1938cac2eb1fe5f9180e31a;hpb=f096b14739c2edfe2b6a0f29c077be80991ce2c1;p=citadel.git diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index afa637a9a..57c55b03d 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -375,17 +375,16 @@ void sanitize_truncated_recipient(char *str) * (What can I say, I'm in a weird mood today...) */ void remove_any_whitespace_to_the_left_or_right_of_at_symbol(char *name) { - unsigned int i; + char *ptr; + if (!name) return; - for (i = 0; i < strlen(name); ++i) { - if (name[i] == '@') { - while (isspace(name[i - 1]) && i > 0) { - strcpy(&name[i - 1], &name[i]); - --i; - } - while (isspace(name[i + 1])) { - strcpy(&name[i + 1], &name[i + 2]); - } + for (ptr=name; *ptr; ++ptr) { + while ( (isspace(*ptr)) && (*(ptr+1)=='@') ) { + strcpy(ptr, ptr+1); + if (ptr > name) --ptr; + } + while ( (*ptr=='@') && (*(ptr+1)!=0) && (isspace(*(ptr+1))) ) { + strcpy(ptr+1, ptr+2); } } } @@ -458,7 +457,6 @@ int alias(char *name) { /* process alias and routing info for mail */ * Caller needs to free the result using free_recipients() */ struct recptypes *validate_recipients(const char *supplied_recipients, const char *RemoteIdentifier, int Flags) { - struct CitContext *CCC = CC; struct recptypes *ret; char *recipients = NULL; char *org_recp; @@ -466,7 +464,6 @@ struct recptypes *validate_recipients(const char *supplied_recipients, const cha char this_recp_cooked[256]; char append[SIZ]; long len; - int num_recps = 0; int i, j; int mailtype; int invalid; @@ -521,7 +518,7 @@ struct recptypes *validate_recipients(const char *supplied_recipients, const cha } /* Now start extracting recipients... */ - + Array *recp_array = array_new(1024); while (!IsEmptyStr(recipients)) { for (i=0; i<=strlen(recipients); ++i) { if (recipients[i] == '\"') in_quotes = 1 - in_quotes; @@ -541,8 +538,12 @@ struct recptypes *validate_recipients(const char *supplied_recipients, const cha striplt(this_recp); if (IsEmptyStr(this_recp)) break; - syslog(LOG_DEBUG, "internet_addressing: evaluating recipient #%d: %s", num_recps, this_recp); - ++num_recps; + syslog(LOG_DEBUG, "internet_addressing: evaluating recipient: %s", this_recp); + array_append(recp_array, this_recp); + } + + for (int r=0; rrecp_room, this_recp); } - else if ( (!strncasecmp(this_recp, "room_", 5)) - && (!CtdlGetRoom(&tempQR, &this_recp_cooked[5])) ) { + else if ( (!strncasecmp(this_recp, "room_", 5)) && (!CtdlGetRoom(&tempQR, &this_recp_cooked[5])) ) { /* Save room so we can restore it later */ - tempQR2 = CCC->room; - CCC->room = tempQR; + tempQR2 = CC->room; + CC->room = tempQR; /* Check permissions to send mail to this room */ err = CtdlDoIHavePermissionToPostInThisRoom( @@ -604,7 +604,7 @@ struct recptypes *validate_recipients(const char *supplied_recipients, const cha } /* Restore room in case something needs it */ - CCC->room = tempQR2; + CC->room = tempQR2; } else if (CtdlGetUser(&tempUS, this_recp) == 0) { @@ -690,6 +690,8 @@ struct recptypes *validate_recipients(const char *supplied_recipients, const cha ); free(recipients); + array_free(recp_array); + return(ret); }