Commit 6942ba6b authored by rswindell's avatar rswindell
Browse files

Added support for auto-detection of incoming UTF-8 messages (default: enabled).

If an incoming message contains no CHRS/CHARSET control line *and* the message
text contains valid UTF-8 character encodings, set the FTN charset value to
UTF-8 so the message will be displayed/handled accordingly.
I did not add checks for header fields (to/from/subject) - we should probably
auto-detect UTF-8 in those as well, but for now, I don't see messages coming
into FidoNet echoes with UTF-8 in the header fields.
Incremented SBBSecho/EchoCfg version to 3.10.
parent c68849a5
......@@ -86,6 +86,8 @@ void global_settings(void)
,cfg.strip_soft_cr ? "Yes":"No");
snprintf(opt[i++],MAX_OPLN-1,"%-30s %-3.3s","Strip Outgoing Line Feeds "
,cfg.strip_lf ? "Yes":"No");
snprintf(opt[i++],MAX_OPLN-1,"%-30s %-3.3s","Auto-detect UTF-8 Messages "
,cfg.auto_utf8 ? "Yes":"No");
snprintf(opt[i++],MAX_OPLN-1,"%-30s %-3.3s","Use Outboxes for Mail Files "
,cfg.use_outboxes ? "Yes":"No");
......@@ -144,6 +146,11 @@ void global_settings(void)
" (ASCII 10) characters from the body text of `exported` EchoMail and\n"
" NetMail messages.\n"
"\n"
"`Auto-detect UTF-8 Messages` instructs SBBSecho to treat incoming\n"
" messages which lack a CHRS/CHARSET control line and contain valid\n"
" UTF-8 character sequences in the message text, as UTF-8 encoded\n"
" messages.\n"
"\n"
"`Use Outboxes for Mail Files` instructs SBBSecho to place outbound\n"
" NetMail and EchoMail files into the configured `Outbox Directory`\n"
" of the relevant linked node. If the linked node has no configured\n"
......@@ -253,6 +260,16 @@ void global_settings(void)
break;
}
case 8:
{
int k = !cfg.auto_utf8;
switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
,"Auto-detect incoming UTF-8 encoded messages",uifcYesNoOpts)) {
case 0: cfg.auto_utf8 = true; break;
case 1: cfg.auto_utf8 = false; break;
}
break;
}
case 9:
{
int k = !cfg.use_outboxes;
switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
......@@ -262,35 +279,35 @@ void global_settings(void)
}
break;
}
case 9:
case 10:
duration_to_vstr(cfg.bsy_timeout, duration, sizeof(duration));
if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "BSY Mutex File Timeout", duration, 10, K_EDIT) > 0)
cfg.bsy_timeout = (ulong)parse_duration(duration);
break;
case 10:
case 11:
duration_to_vstr(cfg.bso_lock_delay, duration, sizeof(duration));
if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "Delay Between BSO Lock Attempts", duration, 10, K_EDIT) > 0)
cfg.bso_lock_delay = (ulong)parse_duration(duration);
break;
case 11:
case 12:
sprintf(str, "%lu", cfg.bso_lock_attempts);
if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "Maximum BSO Lock Attempts", str, 5, K_EDIT|K_NUMBER) > 0)
cfg.bso_lock_attempts = atoi(str);
break;
case 12:
case 13:
uifc.input(WIN_MID|WIN_SAV,0,0
,"BinkP Capabilities (BinkIT)", cfg.binkp_caps, sizeof(cfg.binkp_caps)-1, K_EDIT);
break;
case 13:
case 14:
uifc.input(WIN_MID|WIN_SAV,0,0
,"BinkP Sysop Name (BinkIT)", cfg.binkp_sysop, sizeof(cfg.binkp_sysop)-1, K_EDIT);
break;
case 14:
case 15:
{
int k = !cfg.binkp_plainAuthOnly;
strcpy(opt[0], "Plain-Password Only");
......@@ -308,7 +325,7 @@ void global_settings(void)
break;
}
case 15:
case 16:
{
if(cfg.binkp_plainAuthOnly) {
uifc.msg("CRAM-MD5 authentication/encryption has been disabled globally");
......
......@@ -229,6 +229,7 @@ void get_default_echocfg(sbbsecho_cfg_t* cfg)
cfg->cfgfile_backups = 100;
cfg->auto_add_subs = true;
cfg->auto_add_to_areafile = true;
cfg->auto_utf8 = true;
cfg->min_free_diskspace = 10*1024*1024;
}
......@@ -281,6 +282,7 @@ bool sbbsecho_read_ini(sbbsecho_cfg_t* cfg)
cfg->strip_lf = iniGetBool(ini, ROOT_SECTION, "StripLineFeeds", cfg->strip_lf);
cfg->strip_soft_cr = iniGetBool(ini, ROOT_SECTION, "StripSoftCRs", cfg->strip_soft_cr);
cfg->use_outboxes = iniGetBool(ini, ROOT_SECTION, "UseOutboxes", cfg->use_outboxes);
cfg->auto_utf8 = iniGetBool(ini, ROOT_SECTION, "AutoUTF8", cfg->auto_utf8);
/* EchoMail options: */
cfg->maxbdlsize = (ulong)iniGetBytes(ini, ROOT_SECTION, "BundleSize", 1, cfg->maxbdlsize);
......@@ -523,6 +525,7 @@ bool sbbsecho_write_ini(sbbsecho_cfg_t* cfg)
iniSetBool(&ini, ROOT_SECTION, "StripLineFeeds" ,cfg->strip_lf ,NULL);
iniSetBool(&ini, ROOT_SECTION, "StripSoftCRs" ,cfg->strip_soft_cr ,NULL);
iniSetBool(&ini, ROOT_SECTION, "UseOutboxes" ,cfg->use_outboxes ,NULL);
iniSetBool(&ini, ROOT_SECTION, "AutoUTF8" ,cfg->auto_utf8 ,NULL);
iniSetBool(&ini, ROOT_SECTION, "ConvertTearLines" ,cfg->convert_tear ,NULL);
iniSetBool(&ini, ROOT_SECTION, "FuzzyNetmailZones" ,cfg->fuzzy_zone ,NULL);
iniSetBool(&ini, ROOT_SECTION, "BinkleyStyleOutbound" ,cfg->flo_mailer ,NULL);
......
......@@ -57,6 +57,7 @@
#include "sbbsecho.h"
#include "genwrap.h" /* PLATFORM_DESC */
#include "xpendian.h"
#include "utf8.h"
#define MAX_OPEN_SMBS 10
......@@ -3428,8 +3429,6 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
while(m && fbuf[m-1]<=' ' && fbuf[m-1]>=0) m--;
if(m>l) {
smb_hfield(&msg, FIDOCHARSET, (ushort)(m-l), fbuf+l);
if(smb_msg_is_utf8(&msg))
msg.hdr.auxattr |= MSG_HFIELDS_UTF8;
}
}
......@@ -3545,6 +3544,12 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
taillen--;
stail[taillen]=0;
if(cfg.auto_utf8 && msg.ftn_charset == NULL && !str_is_ascii(fbuf) && utf8_str_is_valid(fbuf))
smb_hfield_str(&msg, FIDOCHARSET, FIDO_CHARSET_UTF8);
if(smb_msg_is_utf8(&msg))
msg.hdr.auxattr |= MSG_HFIELDS_UTF8;
if(subnum==INVALID_SUB && !bodylen && !taillen && cfg.kill_empty_netmail) {
lprintf(LOG_INFO,"Empty NetMail - Ignored ");
smb_freemsgmem(&msg);
......
......@@ -42,7 +42,7 @@
#include "fidodefs.h"
#define SBBSECHO_VERSION_MAJOR 3
#define SBBSECHO_VERSION_MINOR 9
#define SBBSECHO_VERSION_MINOR 10
#define SBBSECHO_PRODUCT_CODE 0x12FF /* from http://ftsc.org/docs/ftscprod.013 */
......@@ -213,6 +213,7 @@ typedef struct {
bool relay_filtered_msgs;
bool auto_add_subs;
bool auto_add_to_areafile;
bool auto_utf8;
bool use_outboxes;
ulong bsy_timeout;
ulong bso_lock_attempts;
......
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