...
 
Commits (2)
  • Rob Swindell's avatar
    Include comment headers in smb_getmsgtxt() returned buffer · 0c68700b
    Rob Swindell authored
    even when GETMSGTXT_PLAIN mode flag is used and the message contains a MIME-encoded plain-text portion. Obviously the GETMSGTXT_NO_HFIELDS exception still applies.
    
    The fixed problem was when forwarding a MIME-encoded email, the forwarding information (and user comment, if supplied) could be suppressed/lost.
    0c68700b
  • Rob Swindell's avatar
    Display message comment headers without relying on smb_getmsgtxt() · 4a824f52
    Rob Swindell authored
    Since we're calling smb_getplaintext() manually here, and its not going to return the comment headers as part of the plain-text (the way smb_getmsgtxt() can), so we need to display find/display the comment headers first.
    4a824f52
......@@ -272,19 +272,19 @@ bool sbbs_t::show_msg(smb_t* smb, smbmsg_t* msg, long p_mode, post_t* post)
show_msghdr(smb, msg);
int comments=0;
for(int i = 0; i < msg->total_hfields; i++)
if(msg->hfield[i].type == SMB_COMMENT) {
bprintf("%s\r\n", (char*)msg->hfield_dat[i]);
comments++;
}
if(comments)
CRLF;
if(msg->hdr.type == SMB_MSG_TYPE_POLL && post != NULL && smb->subnum < cfg.total_subs) {
char* answer;
int longest_answer = 0;
int comments=0;
for(int i = 0; i < msg->total_hfields; i++)
if(msg->hfield[i].type == SMB_COMMENT) {
bprintf("%s\r\n", (char*)msg->hfield_dat[i]);
comments++;
}
if(comments)
CRLF;
for(int i = 0; i < msg->total_hfields; i++) {
if(msg->hfield[i].type != SMB_POLL_ANSWER)
continue;
......@@ -332,7 +332,7 @@ bool sbbs_t::show_msg(smb_t* smb, smbmsg_t* msg, long p_mode, post_t* post)
mnemonics(text[VoteInThisPollNow]);
return true;
}
if((txt=smb_getmsgtxt(smb, msg, 0)) == NULL)
if((txt=smb_getmsgtxt(smb, msg, GETMSGTXT_BODY_ONLY)) == NULL)
return false;
char* p = txt;
if(!(console&CON_RAW_IN)) {
......
......@@ -45,6 +45,7 @@
char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
{
char* buf;
char* preamble;
char* lzhbuf;
char* p;
char* str;
......@@ -107,6 +108,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
buf[l] = 0;
}
}
preamble = strdup(buf);
for(i=0;i<(uint)msg->hdr.total_dfields;i++) {
if(msg->dfield[i].length<=sizeof(xlat))
......@@ -146,6 +148,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
,"%s malloc failure of %ld bytes for LZH buffer"
, __FUNCTION__, length);
free(buf);
free(preamble);
return(NULL);
}
if(smb_fread(smb,lzhbuf,length,smb->sdt_fp) != length) {
......@@ -154,6 +157,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
, __FUNCTION__, length);
free(lzhbuf);
free(buf);
free(preamble);
return(NULL);
}
lzhlen=*(int32_t*)lzhbuf;
......@@ -163,6 +167,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
, __FUNCTION__, l+lzhlen+3L);
free(lzhbuf);
free(buf);
free(preamble);
return(NULL);
}
buf=p;
......@@ -176,6 +181,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
,"%s realloc failure of %ld bytes for text buffer"
, __FUNCTION__, l+length+3L);
free(buf);
free(preamble);
return(NULL);
}
buf=p;
......@@ -196,9 +202,18 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
if(mode&GETMSGTXT_PLAIN) {
char* plaintext = smb_getplaintext(msg, buf);
if(plaintext != NULL)
return plaintext;
if(plaintext != NULL) {
buf = malloc(strlen(preamble) + strlen(plaintext) + 1);
if(buf == NULL)
buf = plaintext;
else {
strcpy(buf, preamble);
strcat(buf, plaintext);
free(plaintext);
}
}
}
free(preamble);
return(buf);
}
......