This commit is contained in:
SJ 2014-07-07 16:45:37 +02:00
parent 6c8809793b
commit bbd81faf0b

View File

@ -192,35 +192,48 @@ int trimBuffer(char *s){
} }
int extractEmail(char *rawmail, char *email){ int extract_verp_address(char *email){
char *p, *q1, *q2; char *p, *p1, *p2;
char puf[SMALLBUFSIZE];
memset(email, 0, SMALLBUFSIZE); // a VERP address is like archive+user=domain.com@myarchive.local
// extract both regular and VERP addresses, eg. if(!email) return 0;
// aaa@aaa.fu and archive+user=domain.com@myarchive.local
p = strchr(rawmail, '<'); if(strlen(email) < 5) return 0;
if(p){
q1 = strchr(p+1, '+'); p1 = strchr(email, '+');
if(q1){ if(p1){
q2 = strchr(q1+1, '='); p2 = strchr(p1, '@');
if(q2){ if(p2 && p2 > p1 + 2){
p = strchr(q2, '@'); if(strchr(p1+1, '=')){
if(p){ memset(puf, 0, sizeof(puf));
*p = '\0';
*q2 = '@'; memcpy(&puf[0], p1+1, p2-p1-1);
snprintf(email, SMALLBUFSIZE-1, "%s", q1+1); p = strchr(puf, '=');
*p = '@'; if(p) *p = '@';
return 1; strcpy(email, puf);
}
} }
} }
}
return 0;
}
int extractEmail(char *rawmail, char *email){
char *p;
memset(email, 0, SMALLBUFSIZE);
p = strchr(rawmail, '<');
if(p){
snprintf(email, SMALLBUFSIZE-1, "%s", p+1); snprintf(email, SMALLBUFSIZE-1, "%s", p+1);
p = strchr(email, '>'); p = strchr(email, '>');
if(p){ if(p){
*p = '\0'; *p = '\0';
extract_verp_address(email);
return 1; return 1;
} }
} }