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

Support quoted filenames in message subjects

"Old style" (e.g. FTN netmail) attachments put the filename(s) in the message subject. Supported quoted-filenames in the message subject (i.e. to support filenames with spaces in them) in addition to the traditional space-delimited filenames. Mixing quoted and space-delimited filenames (for multiple attached files) in a single message subject is supported.
parent 08786fbe
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #1278 passed
...@@ -877,33 +877,40 @@ static ulong sockmimetext(SOCKET socket, const char* prot, CRYPT_SESSION sess, s ...@@ -877,33 +877,40 @@ static ulong sockmimetext(SOCKET socket, const char* prot, CRYPT_SESSION sess, s
static ulong sockmsgtxt(SOCKET socket, const char* prot, CRYPT_SESSION sess, smbmsg_t* msg, char* msgtxt, ulong maxlines) static ulong sockmsgtxt(SOCKET socket, const char* prot, CRYPT_SESSION sess, smbmsg_t* msg, char* msgtxt, ulong maxlines)
{ {
char dirname[MAX_PATH + 1];
char filepath[MAX_PATH + 1]; char filepath[MAX_PATH + 1];
ulong retval; ulong retval;
char* boundary=NULL; char* boundary=NULL;
unsigned i;
str_list_t file_list=NULL; str_list_t file_list=NULL;
str_list_t split;
if(msg->hdr.auxattr&MSG_FILEATTACH) { if(msg->hdr.auxattr&MSG_FILEATTACH) {
if(msg->idx.to != 0)
SAFEPRINTF2(dirname, "%sfile/%04u.in", scfg.data_dir, msg->idx.to);
else
SAFEPRINTF2(dirname, "%sfile/%04u.out", scfg.data_dir, msg->idx.from);
boundary = mimegetboundary(); boundary = mimegetboundary();
file_list = strListInit(); file_list = strListInit();
/* Parse subject (if necessary) */ /* filename(s) in subject */
if(!strListCount(file_list)) { /* filename(s) stored in subject */ char* p = msg->subj;
split=strListSplitCopy(NULL,msg->subj," "); SKIP_WHITESPACE(p);
if(split!=NULL) { while(*p != '\0') {
for(i=0;split[i];i++) { char delim = ' ';
if(msg->idx.to!=0) if(*p == '"') {
SAFEPRINTF3(filepath,"%sfile/%04u.in/%s" delim = '"';
,scfg.data_dir,msg->idx.to,getfname(truncsp(split[i]))); p++;
else
SAFEPRINTF3(filepath,"%sfile/%04u.out/%s"
,scfg.data_dir,msg->idx.from,getfname(truncsp(split[i])));
strListPush(&file_list,filepath);
}
strListFree(&split);
} }
char* tp = strchr(p, delim);
if(tp == NULL && delim != ' ')
break;
*tp = '\0';
SAFEPRINTF2(filepath, "%s/%s", dirname, getfname(truncsp(p)));
strListPush(&file_list, filepath);
if(tp == NULL)
break;
p = tp + 1;
SKIP_WHITESPACE(p);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment