Skip to content
Snippets Groups Projects
Commit abfe3859 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Recognize the "standard" USENET signature delimiter: "\n-- \n"

And separate the saved/imported message text into body and tail (separate SMB msg data fields) automatically to exclude signatures from quoted text.

As requested by Tracker1.
parent eb209e84
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #394 passed
...@@ -63,6 +63,16 @@ int msgbase_open(scfg_t* cfg, smb_t* smb, unsigned int subnum, int* storage, lon ...@@ -63,6 +63,16 @@ int msgbase_open(scfg_t* cfg, smb_t* smb, unsigned int subnum, int* storage, lon
return i; return i;
} }
static uchar* findsig(char* msgbuf)
{
char* tail = strstr(msgbuf, "\n-- \r\n");
if(tail != NULL) {
*tail = '\0';
tail++;
truncsp(msgbuf);
}
return (uchar*)tail;
}
/****************************************************************************/ /****************************************************************************/
/* Posts a message on sub-board number 'subnum' */ /* Posts a message on sub-board number 'subnum' */
...@@ -313,7 +323,7 @@ bool sbbs_t::postmsg(uint subnum, long wm_mode, smb_t* resmb, smbmsg_t* remsg) ...@@ -313,7 +323,7 @@ bool sbbs_t::postmsg(uint subnum, long wm_mode, smb_t* resmb, smbmsg_t* remsg)
if(tags[0]) if(tags[0])
smb_hfield_str(&msg, SMB_TAGS, tags); smb_hfield_str(&msg, SMB_TAGS, tags);
i=smb_addmsg(&smb,&msg,storage,dupechk_hashes,xlat,(uchar*)msgbuf,NULL); i=smb_addmsg(&smb,&msg,storage,dupechk_hashes,xlat,(uchar*)msgbuf, findsig(msgbuf));
free(msgbuf); free(msgbuf);
if(i==SMB_DUPE_MSG) { if(i==SMB_DUPE_MSG) {
...@@ -402,7 +412,7 @@ extern "C" int DLLCALL msg_client_hfields(smbmsg_t* msg, client_t* client) ...@@ -402,7 +412,7 @@ extern "C" int DLLCALL msg_client_hfields(smbmsg_t* msg, client_t* client)
return SMB_SUCCESS; return SMB_SUCCESS;
} }
/* Note: support MSG_BODY only, no tails or other data fields (dfields) */ /* Note: finds signature delimiter automatically and (if applicable) separates msgbuf into body and tail */
/* Adds/generates Message-IDs when needed */ /* Adds/generates Message-IDs when needed */
extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t* client, const char* server, char* msgbuf, smbmsg_t* remsg) extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t* client, const char* server, char* msgbuf, smbmsg_t* remsg)
{ {
...@@ -484,7 +494,10 @@ extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t* ...@@ -484,7 +494,10 @@ extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t*
|| (msg->subj != NULL && !str_is_ascii(msg->subj) && utf8_str_is_valid(msg->subj))) || (msg->subj != NULL && !str_is_ascii(msg->subj) && utf8_str_is_valid(msg->subj)))
msg->hdr.auxattr |= MSG_HFIELDS_UTF8; msg->hdr.auxattr |= MSG_HFIELDS_UTF8;
if((i=smb_addmsg(smb,msg,smb_storage_mode(cfg, smb),dupechk_hashes,xlat,(uchar*)msgbuf, /* tail: */NULL))==SMB_SUCCESS msgbuf = strdup(msgbuf);
if(msgbuf == NULL)
return SMB_FAILURE;
if((i=smb_addmsg(smb,msg,smb_storage_mode(cfg, smb),dupechk_hashes,xlat,(uchar*)msgbuf, findsig(msgbuf)))==SMB_SUCCESS
&& msg->to!=NULL /* no recipient means no header created at this stage */) { && msg->to!=NULL /* no recipient means no header created at this stage */) {
if(smb->subnum == INVALID_SUB) { if(smb->subnum == INVALID_SUB) {
if(msg->to_net.type == NET_FIDO && cfg->netmail_sem[0]) if(msg->to_net.type == NET_FIDO && cfg->netmail_sem[0])
...@@ -519,6 +532,7 @@ extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t* ...@@ -519,6 +532,7 @@ extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t*
} }
} }
} }
free(msgbuf);
return(i); return(i);
} }
......
...@@ -366,10 +366,9 @@ bool sbbs_t::qwk_import_msg(FILE *qwk_fp, char *hdrblk, ulong blocks ...@@ -366,10 +366,9 @@ bool sbbs_t::qwk_import_msg(FILE *qwk_fp, char *hdrblk, ulong blocks
if(!bodylen && !taillen) /* Ignore blank lines at top of message */ if(!bodylen && !taillen) /* Ignore blank lines at top of message */
continue; continue;
if(!taillen && col==3 && bodylen>=3 && body[bodylen-3]=='-' if(!taillen && col==3 && bodylen>=3 && body[bodylen-3]=='-'
&& body[bodylen-2]=='-' && body[bodylen-1]=='-') { && body[bodylen-2]=='-' && (body[bodylen-1]=='-' || body[bodylen-1]==' ')) {
taillen = sprintf(tail, "--%c", body[bodylen-1]); /* DO NOT USE SAFECOPY */
bodylen-=3; bodylen-=3;
strcpy(tail,"---"); /* DO NOT USE SAFECOPY */
taillen=3;
} }
col=0; col=0;
if(taillen) { if(taillen) {
......
...@@ -2282,7 +2282,7 @@ char* process_areafix(fidoaddr_t addr, char* inbuf, const char* password, const ...@@ -2282,7 +2282,7 @@ char* process_areafix(fidoaddr_t addr, char* inbuf, const char* password, const
} }
} }
if(((tp=strstr(p,"---\r"))!=NULL || (tp=strstr(p,"--- "))!=NULL) && if(((tp=strstr(p,"---\r"))!=NULL || (tp=strstr(p,"--- "))!=NULL || (tp=strstr(p,"-- \r"))!=NULL) &&
(*(tp-1)=='\r' || *(tp-1)=='\n')) (*(tp-1)=='\r' || *(tp-1)=='\n'))
*tp=0; *tp=0;
...@@ -3503,7 +3503,8 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum) ...@@ -3503,7 +3503,8 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
if(ch == '\n') if(ch == '\n')
continue; continue;
if(cr && (!strncmp(fbuf+l,"--- ",4) if(cr && (!strncmp(fbuf+l,"--- ",4)
|| !strncmp(fbuf+l,"---\r",4))) || !strncmp(fbuf+l,"---\r",4)
|| !strncmp(fbuf+l,"-- \r",4)))
done=1; /* tear line and down go into tail */ done=1; /* tear line and down go into tail */
else if(cr && !strncmp(fbuf+l," * Origin: ",11) && subnum != INVALID_SUB) { else if(cr && !strncmp(fbuf+l," * Origin: ",11) && subnum != INVALID_SUB) {
p=(char*)fbuf+l+11; p=(char*)fbuf+l+11;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment