From 6a932bb11effe03a0b006ab2806d704bab158296 Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Wed, 23 Feb 2022 00:19:11 -0800 Subject: [PATCH] Fix issue with blind/batch uploaded file descriptions When no file description was provided (e.g. blind/batch file uploads), I noticed that the short file description (summary) could be set to "(null)". This problem was introduced in commit 4bd6f5f67acae1cc5d with the sbbsfile.des creation and post-processing support. I also noticed that the extended description processing in sbbs_t::uploadfile() was not entirely consistent with other methods of adding/uploading files. Let prep_file_desc() do its just of processing the extended description into a suitable short description/summary (including truncation). --- src/sbbs3/upload.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/sbbs3/upload.cpp b/src/sbbs3/upload.cpp index bbe7a8c973..33f043993b 100644 --- a/src/sbbs3/upload.cpp +++ b/src/sbbs3/upload.cpp @@ -68,7 +68,8 @@ bool sbbs_t::uploadfile(file_t* f) } SAFEPRINTF(str,"%ssbbsfile.des",cfg.node_dir); if((stream=fopen(str,"w"))!=NULL) { - fprintf(stream, "%s", f->desc); + if(f->desc != NULL) + fprintf(stream, "%s", f->desc); fclose(stream); } // Note: str (%s) is path/to/sbbsfile.des (used to be the description itself) @@ -98,7 +99,8 @@ bool sbbs_t::uploadfile(file_t* f) if((stream=fopen(str,"r"))!=NULL) { if(fgets(str, sizeof(str), stream)) { truncsp(str); - smb_new_hfield_str(f, SMB_FILEDESC, str); + if(*str) + smb_new_hfield_str(f, SMB_FILEDESC, str); } fclose(stream); } @@ -152,16 +154,10 @@ bool sbbs_t::uploadfile(file_t* f) file_sauce_hfields(f, &sauce); if(f->desc == NULL || f->desc[0] == 0) { - char desc[LEN_FDESC + 1]; + char desc[LEN_EXTDESC + 1]; SAFECOPY(desc, (char*)ext); - strip_exascii(desc, desc); prep_file_desc(desc, desc); - for(i=0;desc[i];i++) - if(IS_ALPHANUMERIC(desc[i])) - break; - if(desc[i] == '\0') - i = 0; - smb_new_hfield_str(f, SMB_FILEDESC, desc + i); + smb_new_hfield_str(f, SMB_FILEDESC, desc); } remove(str); } else -- GitLab