Commit 3d81ec01 authored by rswindell's avatar rswindell
Browse files

smb_getplaintext() now returns NULL if there is no MIME-encoded plain-text.

This allows a message displayer to indicate to the user that some MIME-decoding
took place.
parent c87e337c
......@@ -184,8 +184,11 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
*(buf+l)=0;
}
if(mode&GETMSGTXT_PLAIN)
buf = smb_getplaintext(msg, buf);
if(mode&GETMSGTXT_PLAIN) {
char* plaintext = smb_getplaintext(msg, buf);
if(plaintext != NULL)
return plaintext;
}
return(buf);
}
......@@ -381,6 +384,7 @@ static char* mime_getcontent(char* buf, const char* content_type, const char* co
}
/* Get just the plain-text portion of a MIME-encoded message body */
/* Returns NULL if there is no MIME-encoded plain-text portion of the message */
char* SMBCALL smb_getplaintext(smbmsg_t* msg, char* buf)
{
int i;
......@@ -397,23 +401,24 @@ char* SMBCALL smb_getplaintext(smbmsg_t* msg, char* buf)
}
}
if(content_type == NULL) /* not MIME */
return buf;
return NULL;
txt = mime_getcontent(buf, content_type, "text/plain", 0, &xfer_encoding
,/* attachment: */NULL, /* index: */0);
if(txt != NULL) {
memmove(buf, txt, strlen(txt)+1);
if(*buf == 0)
return buf;
if(xfer_encoding == CONTENT_TRANFER_ENCODING_QUOTED_PRINTABLE)
qp_decode(buf);
else if(xfer_encoding == CONTENT_TRANFER_ENCODING_BASE64) {
char* decoded = strdup(buf);
if(decoded == NULL)
return buf;
if(b64_decode(decoded, strlen(decoded), buf, strlen(buf)) > 0)
strcpy(buf, decoded);
free(decoded);
}
if(txt == NULL)
return NULL;
memmove(buf, txt, strlen(txt)+1);
if(*buf == 0) /* No decoding necessary */
return buf;
if(xfer_encoding == CONTENT_TRANFER_ENCODING_QUOTED_PRINTABLE)
qp_decode(buf);
else if(xfer_encoding == CONTENT_TRANFER_ENCODING_BASE64) {
char* decoded = strdup(buf);
if(decoded == NULL)
return NULL;
if(b64_decode(decoded, strlen(decoded), buf, strlen(buf)) > 0)
strcpy(buf, decoded);
free(decoded);
}
return buf;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment