Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 2317bc41 authored by rswindell's avatar rswindell

Create/use a common strip_char() function, can strip chars from a string

in-place or by also copying to a new string in the process.

Don't string "soft-CRs" (0x8d) from UTF-8 encoded FTN messages, ever.

Default strip_soft_cr SBBSecho setting to true/on.
parent 41787928
...@@ -2631,24 +2631,6 @@ static int chk_received_hdr(SOCKET socket,const char* prot,const char *buf,IN_AD ...@@ -2631,24 +2631,6 @@ static int chk_received_hdr(SOCKET socket,const char* prot,const char *buf,IN_AD
return(dnsbl_result->s_addr); return(dnsbl_result->s_addr);
} }
static void strip_char(char* str, char ch)
{
char* src;
char* p;
char* tmp = strdup(str);
if(tmp == NULL)
return;
p=tmp;
for(src = str; *src; src++) {
if(*src != ch)
*(p++) = *src;
}
*p=0;
strcpy(str, tmp);
free(tmp);
}
static void parse_mail_address(char* p static void parse_mail_address(char* p
,char* name, size_t name_len ,char* name, size_t name_len
,char* addr, size_t addr_len) ,char* addr, size_t addr_len)
...@@ -2684,7 +2666,7 @@ static void parse_mail_address(char* p ...@@ -2684,7 +2666,7 @@ static void parse_mail_address(char* p
if(tp) *tp=0; if(tp) *tp=0;
sprintf(name,"%.*s",(int)name_len,p); sprintf(name,"%.*s",(int)name_len,p);
truncsp(name); truncsp(name);
strip_char(name, '\\'); strip_char(name, name, '\\');
} }
/* Decode quoted-printable content-transfer-encoded text */ /* Decode quoted-printable content-transfer-encoded text */
...@@ -4015,7 +3997,7 @@ static void smtp_thread(void* arg) ...@@ -4015,7 +3997,7 @@ static void smtp_thread(void* arg)
continue; continue;
} }
/* RFC822 Header parsing */ /* RFC822 Header parsing */
strip_char(buf, '\r'); /* There should be no bare carriage returns in header fields */ strip_char(buf, buf, '\r'); /* There should be no bare carriage returns in header fields */
if(startup->options&MAIL_OPT_DEBUG_RX_HEADER) if(startup->options&MAIL_OPT_DEBUG_RX_HEADER)
lprintf(LOG_DEBUG,"%04d %s %s",socket, client.protocol, buf); lprintf(LOG_DEBUG,"%04d %s %s",socket, client.protocol, buf);
......
...@@ -230,6 +230,7 @@ void get_default_echocfg(sbbsecho_cfg_t* cfg) ...@@ -230,6 +230,7 @@ void get_default_echocfg(sbbsecho_cfg_t* cfg)
cfg->auto_add_subs = true; cfg->auto_add_subs = true;
cfg->auto_add_to_areafile = true; cfg->auto_add_to_areafile = true;
cfg->auto_utf8 = true; cfg->auto_utf8 = true;
cfg->strip_soft_cr = true;
cfg->min_free_diskspace = 10*1024*1024; cfg->min_free_diskspace = 10*1024*1024;
} }
......
...@@ -1160,6 +1160,7 @@ extern "C" { ...@@ -1160,6 +1160,7 @@ extern "C" {
DLLEXPORT char * strip_space(const char *str, char* dest); DLLEXPORT char * strip_space(const char *str, char* dest);
DLLEXPORT char * prep_file_desc(const char *str, char* dest); DLLEXPORT char * prep_file_desc(const char *str, char* dest);
DLLEXPORT char * strip_ctrl(const char *str, char* dest); DLLEXPORT char * strip_ctrl(const char *str, char* dest);
DLLEXPORT char * strip_char(const char* str, char* dest, char);
DLLEXPORT char * net_addr(net_t* net); DLLEXPORT char * net_addr(net_t* net);
DLLEXPORT BOOL valid_ctrl_a_attr(char a); DLLEXPORT BOOL valid_ctrl_a_attr(char a);
DLLEXPORT BOOL valid_ctrl_a_code(char a); DLLEXPORT BOOL valid_ctrl_a_code(char a);
......
...@@ -3475,8 +3475,7 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum) ...@@ -3475,8 +3475,7 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
continue; continue;
} }
if(ch == '\n' || if(ch == '\n')
(ch == FIDO_SOFT_CR && cfg.strip_soft_cr))
continue; continue;
if(cr && (!strncmp((char *)fbuf+l,"--- ",4) if(cr && (!strncmp((char *)fbuf+l,"--- ",4)
|| !strncmp((char *)fbuf+l,"---\r",4))) || !strncmp((char *)fbuf+l,"---\r",4)))
...@@ -3549,6 +3548,10 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum) ...@@ -3549,6 +3548,10 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
if(smb_msg_is_utf8(&msg)) if(smb_msg_is_utf8(&msg))
msg.hdr.auxattr |= MSG_HFIELDS_UTF8; msg.hdr.auxattr |= MSG_HFIELDS_UTF8;
else {
if(cfg.strip_soft_cr)
strip_char((const char*)sbody, (char*)sbody, FIDO_SOFT_CR);
}
if(subnum==INVALID_SUB && !bodylen && !taillen && cfg.kill_empty_netmail) { if(subnum==INVALID_SUB && !bodylen && !taillen && cfg.kill_empty_netmail) {
lprintf(LOG_INFO,"Empty NetMail - Ignored "); lprintf(LOG_INFO,"Empty NetMail - Ignored ");
......
...@@ -115,6 +115,21 @@ char* strip_space(const char *str, char* dest) ...@@ -115,6 +115,21 @@ char* strip_space(const char *str, char* dest)
return dest; return dest;
} }
char* strip_char(const char* str, char* dest, char ch)
{
const char* src;
if(dest == NULL && (dest = strdup(str)) == NULL)
return NULL;
char* retval = dest;
for(src = str; *src != '\0'; src++) {
if(*src != ch)
*(dest++) = *src;
}
*dest = '\0';
return retval;
}
char* prep_file_desc(const char *str, char* dest) char* prep_file_desc(const char *str, char* dest)
{ {
int i,j; int i,j;
......
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