X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Finternet_addressing.c;h=c2131cbff46ce421a37225fb78b21772dbd9ceba;hb=7ae2110eee47cd1cce79ccb9ab1e64b8ab5472ac;hp=a1b0a37e176c84748abdb35f90d6202a5b2a5720;hpb=b03aed62997f838e8b75d12839398a999a8f9183;p=citadel.git diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index a1b0a37e1..c2131cbff 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -13,18 +13,7 @@ #include #include #include - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - +#include #include #include #include @@ -194,7 +183,7 @@ void utf8ify_rfc822_string(char *buf) { } else if (!strcasecmp(encoding, "Q")) { /**< quoted-printable */ size_t len; - long pos; + unsigned long pos; len = strlen(istr); pos = 0; @@ -331,7 +320,7 @@ int CtdlHostAlias(char *fqdn) { */ int CtdlIsMe(char *addr, int addr_buf_len) { - struct recptypes *recp; + recptypes *recp; int i; recp = validate_recipients(addr, NULL, 0); @@ -355,25 +344,6 @@ int CtdlIsMe(char *addr, int addr_buf_len) } -/* - * Citadel protocol command to do the same - */ -void cmd_isme(char *argbuf) { - char addr[256]; - - if (CtdlAccessCheck(ac_logged_in)) return; - extract_token(addr, argbuf, 0, '|', sizeof addr); - - if (CtdlIsMe(addr, sizeof addr)) { - cprintf("%d %s\n", CIT_OK, addr); - } - else { - cprintf("%d Not you.\n", ERROR + ILLEGAL_VALUE); - } - -} - - /* If the last item in a list of recipients was truncated to a partial address, * remove it completely in order to avoid choking libSieve */ @@ -407,7 +377,7 @@ void sanitize_truncated_recipient(char *str) */ void remove_any_whitespace_to_the_left_or_right_of_at_symbol(char *name) { - int i; + unsigned int i; for (i = 0; i < strlen(name); ++i) { if (name[i] == '@') { @@ -461,10 +431,11 @@ int alias(char *name) strcpy(name, &name[1]); aaa[strlen(aaa) - 1] = 0; strcpy(bbb, ""); - for (a = 0; a < strlen(aaa); ++a) { + for (a = 0; aaa[a] != '\0'; ++a) { if (aaa[a] == ',') { strcpy(bbb, &aaa[a + 1]); aaa[a] = 0; + break; } } if (!strcasecmp(name, aaa)) @@ -482,11 +453,12 @@ int alias(char *name) } /* Change "user @ xxx" to "user" if xxx is an alias for this host */ - for (a=0; a\n", name); + break; } } } @@ -550,11 +522,11 @@ int alias(char *name) * * Caller needs to free the result using free_recipients() */ -struct recptypes *validate_recipients(const char *supplied_recipients, - const char *RemoteIdentifier, - int Flags) { +recptypes *validate_recipients(const char *supplied_recipients, + const char *RemoteIdentifier, + int Flags) { struct CitContext *CCC = CC; - struct recptypes *ret; + recptypes *ret; char *recipients = NULL; char *org_recp; char this_recp[256]; @@ -573,11 +545,11 @@ struct recptypes *validate_recipients(const char *supplied_recipients, int in_quotes = 0; /* Initialize */ - ret = (struct recptypes *) malloc(sizeof(struct recptypes)); + ret = (recptypes *) malloc(sizeof(recptypes)); if (ret == NULL) return(NULL); /* Set all strings to null and numeric values to zero */ - memset(ret, 0, sizeof(struct recptypes)); + memset(ret, 0, sizeof(recptypes)); if (supplied_recipients == NULL) { recipients = strdup(""); @@ -804,9 +776,9 @@ struct recptypes *validate_recipients(const char *supplied_recipients, /* - * Destructor for struct recptypes + * Destructor for recptypes */ -void free_recipients(struct recptypes *valid) { +void free_recipients(recptypes *valid) { if (valid == NULL) { return; @@ -1008,11 +980,16 @@ void unfold_rfc822_field(char **field, char **FieldEnd) sField < pFieldEnd; pField++, sField++) { - if ((*sField=='\r') || (*sField=='\n')) { - sField++; - if (*sField == '\n') - sField++; - *pField = *sField; + if ((*sField=='\r') || (*sField=='\n')) + { + int Offset = 1; + while (((*(sField + Offset) == '\r') || + (*(sField + Offset) == '\n') || + (isspace(*(sField + Offset)))) && + (sField + Offset < pFieldEnd)) + Offset ++; + sField += Offset; + *pField = *sField; } else { if (*sField=='\"') quote = 1 - quote; @@ -1062,11 +1039,15 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) strcpy(name, &name[1]); /* and anything to the right of a @ or % */ - for (a = 0; a < strlen(name); ++a) { - if (name[a] == '@') + for (a = 0; name[a] != '\0'; ++a) { + if (name[a] == '@') { name[a] = 0; - if (name[a] == '%') + break; + } + if (name[a] == '%') { name[a] = 0; + break; + } } /* but if there are parentheses, that changes the rules... */ @@ -1082,9 +1063,11 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) strcpy(&name[0], &name[1]); } strcpy(&name[0], &name[1]); - for (a = 0; a < strlen(name); ++a) - if (name[a] == 34) + for (a = 0; name[a] != '\0'; ++a) + if (name[a] == 34) { name[a] = 0; + break; + } } /* extract user id */ strcpy(user, rfc822); @@ -1102,11 +1085,15 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) strcpy(user, &user[1]); /* and anything to the right of a @ or % */ - for (a = 0; a < strlen(user); ++a) { - if (user[a] == '@') + for (a = 0; user[a] != '\0'; ++a) { + if (user[a] == '@') { user[a] = 0; - if (user[a] == '%') + break; + } + if (user[a] == '%') { user[a] = 0; + break; + } } @@ -1145,9 +1132,11 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) strcpy(node, &node[1]); /* now get rid of the user portion of a node!user string */ - for (a = 0; a < strlen(node); ++a) - if (node[a] == '!') + for (a = 0; node[a] != '\0'; ++a) + if (node[a] == '!') { node[a] = 0; + break; + } } /* strip leading and trailing spaces in all strings */ @@ -1703,12 +1692,3 @@ char *harvest_collected_addresses(struct CtdlMessage *msg) { } return(coll); } - - -CTDL_MODULE_INIT(internet_addressing) -{ - if (!threading) { - CtdlRegisterProtoHook(cmd_isme, "ISME", "Determine whether an email address belongs to a user"); - } - return "internet_addressing"; -}