From: Jean-Marc Pigeon (Delson) Date: Thu, 22 May 2025 00:43:05 +0000 (-0400) Subject: Able to transmit '.' within email data flow X-Git-Tag: tag-0.8~88 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=0ded7011a52b69ccbaa4696289ae0ad7d630a32d;p=jmp%2Fmailleur Able to transmit '.' within email data flow --- diff --git a/app/feeder.c b/app/feeder.c index b6dd848..8e51258 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -144,21 +144,21 @@ static _Bool dosenddata(FEEDTYP *fd) int status; char *line; -char *action; _Bool empty; +char *action; char data[300]; int phase; _Bool proceed; status=false; line=(char *)0; -action="data"; empty=false; +action="DATA"; (void) strcpy(data,""); phase=0; proceed=true; while (proceed==true) { - (void) rou_alert(0,"%s phase='%d'",OPEP,phase); + //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase); switch (phase) { case 0 : //Transmit "DATA" to remote if (dooutgoing(fd->socptr,action)!=(strlen(action)+2)) @@ -173,7 +173,6 @@ while (proceed==true) { int code; code=0; - (void) rou_alert(0,"%s JMPDBG line=<%s>",OPEP,line); (void) sscanf(line,"%d",&code); if (code!=DATAOK) phase=999; @@ -182,23 +181,38 @@ while (proceed==true) { break; case 3 : // while (fgets(data,sizeof(data),fd->datatst)!=(char *)0) { + _Bool completed; + + completed=true; (void) eml_removecrlf(data); - (void) dooutgoing(fd->socptr,data); - if ((empty==true)&&(strcmp(data,".")==0)) { - phase++; //Eveything is fine - break; + switch (data[0]) { + case 'D' : + if ((strcmp(data+2,".")==0)&&(empty==true)) + (void) strcat(data,"."); + (void) dooutgoing(fd->socptr,data+2); + empty=(strlen(data+2)==0); + completed=false; + break; + case 'C' : + if (data[2]=='.') { + (void) dooutgoing(fd->socptr,""); + (void) dooutgoing(fd->socptr,"."); + } + else + (void) rou_alert(0,"%s Unexpected data close <%s> (Bug?)", + OPEP,data); + break; + default : + (void) rou_alert(0,"%s Unexpected data to be send <%s> (Bug?)", + OPEP,data); + break; + } + if (completed==true) { + status=true; + break; //All data sent. } - empty=false; - if (strlen(data)==0) - empty=true; } break; - case 4 : //phase reached only by data exhaustion - phase=999; //Trouble trouble - break; - case 5 : //all data sent lets say it is good - status=true; - break; default : //SAFE Guard proceed=false; break; diff --git a/data-feed/feed02.tst b/data-feed/feed02.tst index 0ab50ab..cff9b24 100644 --- a/data-feed/feed02.tst +++ b/data-feed/feed02.tst @@ -2,9 +2,6 @@ #==================================================== T:Sending a very Simple Email R:220 mailleur.example.com ESMTP (cleartext) emlrcvr... -C:ORGN 127.127.0.2 -R:220 mailleur.example.com ESMTP (cleartext) emlrcvr... -#C:WAIT 100 #==================================================== S:HELO example.com #R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.127.0.2/feed2.example.com] @@ -22,18 +19,20 @@ R:250 2.6.4 Address accepted #------------------------------------------------------------------------- #-sending data C:DATA -Subject: Very Simple email contents -From: Maitre Post -To: Maitre WEB - -FIRST Line -SECOND Line -LAST Line - -this is a line with a dot -.. -end -. +D:Subject: Very Simple email contents +D:From: Maitre Post +D:To: Maitre WEB +D: +D:FIRST Line +D:SECOND Line +D:LAST Line +D:. +D:this is a line with a dot +D: +D:. +D:end +D:ligne court| +C:. #------------------------------------------------------------------------- R:250 3.5.3 Message accepted for delivery S:QUIT @@ -58,13 +57,14 @@ R:250 2.6.4 Address accepted #------------------------------------------------------------------------- #-sending data C:DATA -Subject: Second email contents - -SECOND FIRST Line -SECOND SECOND Line -SECOND LAST Line - -. +D:Subject: Second email contents +D: +D:SECOND FIRST Line +D:SECOND SECOND Line +D:SECOND LAST Line +D: +D: +C:. #------------------------------------------------------------------------- R:250 3.5.3 Message accepted for delivery S:QUIT @@ -88,13 +88,13 @@ R:250 2.6.4 Address accepted #------------------------------------------------------------------------- #-sending data C:DATA -Subject: Third email contents - -THIRD FIRST Line -THIRD SECOND Line -THIRD LAST Line - -. +D:Subject: Third email contents +D: +D:THIRD FIRST Line +D:THIRD SECOND Line +D:THIRD LAST Line +D: +C:. #------------------------------------------------------------------------- R:250 3.5.3 Message accepted for delivery S:QUIT diff --git a/data-feed/xxfeed.tst b/data-feed/xxfeed.tst index 0ab50ab..cff9b24 100644 --- a/data-feed/xxfeed.tst +++ b/data-feed/xxfeed.tst @@ -2,9 +2,6 @@ #==================================================== T:Sending a very Simple Email R:220 mailleur.example.com ESMTP (cleartext) emlrcvr... -C:ORGN 127.127.0.2 -R:220 mailleur.example.com ESMTP (cleartext) emlrcvr... -#C:WAIT 100 #==================================================== S:HELO example.com #R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.127.0.2/feed2.example.com] @@ -22,18 +19,20 @@ R:250 2.6.4 Address accepted #------------------------------------------------------------------------- #-sending data C:DATA -Subject: Very Simple email contents -From: Maitre Post -To: Maitre WEB - -FIRST Line -SECOND Line -LAST Line - -this is a line with a dot -.. -end -. +D:Subject: Very Simple email contents +D:From: Maitre Post +D:To: Maitre WEB +D: +D:FIRST Line +D:SECOND Line +D:LAST Line +D:. +D:this is a line with a dot +D: +D:. +D:end +D:ligne court| +C:. #------------------------------------------------------------------------- R:250 3.5.3 Message accepted for delivery S:QUIT @@ -58,13 +57,14 @@ R:250 2.6.4 Address accepted #------------------------------------------------------------------------- #-sending data C:DATA -Subject: Second email contents - -SECOND FIRST Line -SECOND SECOND Line -SECOND LAST Line - -. +D:Subject: Second email contents +D: +D:SECOND FIRST Line +D:SECOND SECOND Line +D:SECOND LAST Line +D: +D: +C:. #------------------------------------------------------------------------- R:250 3.5.3 Message accepted for delivery S:QUIT @@ -88,13 +88,13 @@ R:250 2.6.4 Address accepted #------------------------------------------------------------------------- #-sending data C:DATA -Subject: Third email contents - -THIRD FIRST Line -THIRD SECOND Line -THIRD LAST Line - -. +D:Subject: Third email contents +D: +D:THIRD FIRST Line +D:THIRD SECOND Line +D:THIRD LAST Line +D: +C:. #------------------------------------------------------------------------- R:250 3.5.3 Message accepted for delivery S:QUIT diff --git a/lib/lvleml.c b/lib/lvleml.c index e59a295..c8876c8 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -307,18 +307,20 @@ static _Bool getdata(CONTYP *contact) #define OPEP "lvleml.c:getdata," _Bool done; -_Bool empty; FILE *queue; +_Bool empty; +_Bool completed; int phase; _Bool proceed; done=false; -empty=false; queue=(FILE *)0; +empty=false; +completed=false; phase=0; proceed=setdirectives(contact,"tmp"); while (proceed==true) { - (void) rou_alert(0,"JMPDBG %s phase='%d' empty='%d'",OPEP,phase,empty); + //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase); switch (phase) { case 0 : //opening the queue email if ((queue=eml_createqfile(contact->cursesid,""))==(FILE *)0) @@ -333,8 +335,7 @@ while (proceed==true) { DATAOK,"End data with ."); break; case 3 : //get incoming line, detect 'single dot' as end - while (proceed==true) { - int completed; + while (completed==false) { int got; char *line; @@ -344,31 +345,31 @@ while (proceed==true) { phase=999; //trouble trouble break; //exiting loop } - if ((empty==false)||(strcmp(line,".")!=0)) { - if (strcmp(line,"..")==0) - line[1]='\000'; - (void) fprintf(queue,"%s\n",line); - } - else + if ((empty==true)&&(strcmp(line,".")==0)) { completed=true; - empty=(strlen(line)==0); + } + else { + if (empty==true) { + (void) fprintf(queue,"\n"); + if (strcmp(line,"..")==0) + line[1]='\000'; //removing double dot + } + empty=(strlen(line)==0); + if (empty==false) + (void) fprintf(queue,"%s\n",line); + } line=rou_freestr(line); - if (completed==true) - break; } break; - case 4 : //just display line - empty=false; - break; - case 5 : //got all data + case 4 : //got all data if (eml_closeqfile(queue)<0) phase=999; //Trouble trouble break; - case 6 : //renameing directive + case 5 : //renameing directive if (eml_renameqfile(contact->cursesid,"tmp",EXTRANS)==false) phase=999; //Trouble trouble break; - case 7 : //everything fine + case 6 : //everything fine (void) transmit(contact,"%d 3.5.3 %s", CMDOK,"Message accepted for delivery"); done=true; @@ -698,7 +699,9 @@ while (proceed==true) { "condition=<%s>",str); //(void) rou_alert(0,"%s exit status='%d'",OPEP,status); break; //no need to go further + } + (void) rou_alert(0,"%s JMPDBG got <%s>",OPEP,line); (void) log_fprintlog(contact->logptr,false,"%s",line); code=eml_getcode(line); switch (code) {