From 68c5cc783b518571f3ab1d25179a1bcf7015a7ce Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 18 Jul 2021 13:43:00 -0400 Subject: [PATCH] A bit of prep work to bring back the global alias table. This time I want to be able to expand aliases to multiple recipients, so it will be a bit more complex. This commit enhances validate_recipients() to read the recipient list into an array before processing. --- citadel/internet_addressing.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 68daf8854..57c55b03d 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -457,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; @@ -465,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; @@ -520,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; @@ -540,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; rroom; - CCC->room = tempQR; + tempQR2 = CC->room; + CC->room = tempQR; /* Check permissions to send mail to this room */ err = CtdlDoIHavePermissionToPostInThisRoom( @@ -602,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) { @@ -688,6 +690,8 @@ struct recptypes *validate_recipients(const char *supplied_recipients, const cha ); free(recipients); + array_free(recp_array); + return(ret); } -- 2.30.2