Commits (4)
......@@ -30,6 +30,7 @@
#include "scfglib.h"
#include "sauce.h"
#include "crc32.h"
#include "utf8.h"
/* libarchive: */
#include <archive.h>
......@@ -1082,10 +1083,13 @@ char* prep_file_desc(const char* ext, char* dest)
char* src;
char* buf = strdup(ext);
if(buf == NULL)
src = (char*)ext;
else {
src = buf;
strip_ctrl(src, src);
return NULL;
src = buf;
strip_ctrl(src, src);
if(!str_is_ascii(src)) {
if(utf8_str_is_valid(src))
utf8_to_cp437_inplace(src);
strip_cp437_graphics(src, src);
}
FIND_ALPHANUMERIC(src);
......
......@@ -506,7 +506,7 @@ typedef enum { /* Values for xtrn_t.event */
#define LEN_ZIPCODE 10 /* Zip/Postal code */
#define LEN_MODEM 8 /* User modem type description */
#define LEN_FDESC 58 /* File description (summary) */
#define LEN_EXTDESC 4000 /* Extended file description */
#define LEN_EXTDESC 5000 /* Extended file description */
#define LEN_TITLE 70 /* Message title */
#define LEN_MAIN_CMD 28 /* Unused Storage in user.dat */
#define LEN_COLS 3
......
......@@ -68,7 +68,7 @@ char* strip_ctrl(const char *str, char* dest)
if(str[i]=='<' && j)
j--;
}
else if((uchar)str[i]>=' ')
else if((uchar)str[i]>=' ' && str[i] != DEL)
dest[j++]=str[i];
}
dest[j]=0;
......@@ -215,6 +215,20 @@ char* strip_exascii(const char *str, char* dest)
return dest;
}
char* strip_cp437_graphics(const char *str, char* dest)
{
int i,j;
if(dest==NULL && (dest=strdup(str))==NULL)
return NULL;
for(i=j=0;str[i];i++)
if((uchar)str[i] <= (uchar)CP437_INVERTED_EXCLAMATION_MARK
|| (uchar)str[i] >= (uchar)CP437_GREEK_SMALL_LETTER_ALPHA)
dest[j++]=str[i];
dest[j]=0;
return dest;
}
char* strip_space(const char *str, char* dest)
{
int i,j;
......
......@@ -55,6 +55,7 @@ DLLEXPORT str_list_t trashcan_list(scfg_t* cfg, const char* name);
DLLEXPORT char * convert_ansi(const char* src, char* dest, size_t, int width, BOOL ice_color);
DLLEXPORT char * strip_ansi(char* str);
DLLEXPORT char * strip_exascii(const char *str, char* dest);
DLLEXPORT char * strip_cp437_graphics(const char *str, char* dest);
DLLEXPORT char * strip_space(const char *str, char* dest);
DLLEXPORT char * strip_ctrl(const char *str, char* dest);
DLLEXPORT char * strip_char(const char* str, char* dest, char);
......
......@@ -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
......