...
 
Commits (2)
......@@ -63,6 +63,16 @@ int msgbase_open(scfg_t* cfg, smb_t* smb, unsigned int subnum, int* storage, lon
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' */
......@@ -313,7 +323,7 @@ bool sbbs_t::postmsg(uint subnum, long wm_mode, smb_t* resmb, smbmsg_t* remsg)
if(tags[0])
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);
if(i==SMB_DUPE_MSG) {
......@@ -402,7 +412,7 @@ extern "C" int DLLCALL msg_client_hfields(smbmsg_t* msg, client_t* client)
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 */
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*
|| (msg->subj != NULL && !str_is_ascii(msg->subj) && utf8_str_is_valid(msg->subj)))
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 */) {
if(smb->subnum == INVALID_SUB) {
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*
}
}
}
free(msgbuf);
return(i);
}
......
......@@ -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 */
continue;
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;
strcpy(tail,"---"); /* DO NOT USE SAFECOPY */
taillen=3;
}
col=0;
if(taillen) {
......
......@@ -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=0;
......@@ -3503,7 +3503,8 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
if(ch == '\n')
continue;
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 */
else if(cr && !strncmp(fbuf+l," * Origin: ",11) && subnum != INVALID_SUB) {
p=(char*)fbuf+l+11;
......
......@@ -716,7 +716,7 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *subj, long mode,
while(!feof(sig)) {
if(!fgets(str,sizeof(str),sig))
break;
truncsp(str);
truncnl(str);
if(utf8) {
char buf[sizeof(str)*4];
cp437_to_utf8_str(str, buf, sizeof(buf) - 1, /* minval: */'\x02');
......