diff --git a/docs/notework.txt b/docs/notework.txt index d3d2dbe..63f7f18 100644 --- a/docs/notework.txt +++ b/docs/notework.txt @@ -12,6 +12,14 @@ ______________________________________________________________________ Notes for GoldED+ 1.1.5, December xx 2000 ______________________________________________________________________ +- Added some improvements for better charset handling. + +- Fixed decoding of MIME-encoded From and To fields. + +- Fixed block keyboard mode under Win9x/ME. + +- Fixed crash if GoldED+ was unable to open Crashmail II config. + + If filenames specified without path and File Attach attribute is set Attachpath automatically prepended to every filename. diff --git a/golded3/geline.cpp b/golded3/geline.cpp index 54d1fad..af32f4f 100644 --- a/golded3/geline.cpp +++ b/golded3/geline.cpp @@ -2016,79 +2016,81 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) { } if(kludgetype == FSC_I51) { msg->i51 = true; - if(getvalue) { - // Convert FSC-0051.003 to FSC-0054.003 - strcpy(chsbuf, "LATIN-1"); - chslev = LoadCharset(chsbuf, CFG->xlatlocalset); - if(chslev) { - level = msg->charsetlevel = chslev; - strcpy(msg->charset, chsbuf); - } + // Convert FSC-0051.003 to FSC-0054.003 + strcpy(chsbuf, "LATIN-1"); + chslev = LoadCharset(chsbuf, CFG->xlatlocalset); + if(chslev) { + level = msg->charsetlevel = chslev; + strcpy(msg->charset, chsbuf); } } else if(kludgetype == FSC_CHARSET) { - if(getvalue) { - *chsbuf = NUL; - qpencoded = striinc("LATIN1QP", ptr) ? true : false; - strxcpy(chsbuf, qpencoded ? "LATIN-1" : ptr, sizeof(chsbuf)); - // Workaround for buggy mailreaders which stores '_' in charset name - strchg(chsbuf,'_',' '); + *chsbuf = NUL; + qpencoded = striinc("LATIN1QP", ptr) ? true : false; + strxcpy(chsbuf, qpencoded ? "LATIN-1" : ptr, sizeof(chsbuf)); + // Workaround for buggy mailreaders which stores '_' in charset name + strchg(chsbuf,'_',' '); + chslev = LoadCharset(chsbuf, CFG->xlatlocalset); + if(chslev) { + level = msg->charsetlevel = chslev; + strcpy(msg->charset, chsbuf); + } + if(*msg->charset == NUL) + strcpy(msg->charset, chsbuf); + } + else if(kludgetype == RFC_CONTENT_TYPE) { + // Content-Type: text/plain; charset="us-ascii" + const char *mime_charset = striinc("charset=", ptr); + if(mime_charset != NULL) { + if(mime_charset[8] == '\"') { + strxcpy(chsbuf, mime_charset+9, sizeof(chsbuf)); + char *quote = strchr(chsbuf, '\"'); + if(quote != NULL) *quote = NUL; + } + else + strxcpy(chsbuf, strrword(mime_charset+8), sizeof(chsbuf)); chslev = LoadCharset(chsbuf, CFG->xlatlocalset); if(chslev) { level = msg->charsetlevel = chslev; strcpy(msg->charset, chsbuf); } + if(*msg->charset == NUL) + strcpy(msg->charset, chsbuf); + gotmime = true; } - } - else if(kludgetype == RFC_CONTENT_TYPE) { - if(getvalue) { - if(striinc("iso-8859-1", ptr)) { - strcpy(chsbuf, "LATIN-1"); - chslev = LoadCharset(chsbuf, CFG->xlatlocalset); - if(chslev) { - level = msg->charsetlevel = chslev; - strcpy(msg->charset, chsbuf); - } - gotmime = true; - } - if(check_multipart(ptr, keptr, boundary)) { - gotmultipart = true; - gotmime = true; - } + if(check_multipart(ptr, keptr, boundary)) { + gotmultipart = true; + gotmime = true; } } else if(kludgetype == RFC_CONTENT_TRANSFER_ENCODING) { - if(getvalue) { - if(striinc("quoted-printable", ptr)) { - qpencoded = true; - msg->charsetencoding |= GCHENC_QP; - if(striinc("LATIN-1", msg->charset)) { - strcpy(chsbuf, "LATIN1QP"); - chslev = LoadCharset("LATIN-1", CFG->xlatlocalset); - if(chslev) { - level = msg->charsetlevel = chslev; - strcpy(msg->charset, chsbuf); - } + if(striinc("quoted-printable", ptr)) { + qpencoded = true; + msg->charsetencoding |= GCHENC_QP; + // ASA: What the stuff below for? I never saw such messages... + if(striinc("LATIN-1", msg->charset)) { + strcpy(chsbuf, "LATIN1QP"); + chslev = LoadCharset("LATIN-1", CFG->xlatlocalset); + if(chslev) { + level = msg->charsetlevel = chslev; + strcpy(msg->charset, chsbuf); } } } } else if(kludgetype == RFC_X_CHARSET) { - if(getvalue) { - if(not gotmime) { - strcpy(chsbuf, (striinc("8859-1", ptr) or striinc("Latin1", ptr)) ? "LATIN-1" : CFG->xlatlocalset); - chslev = LoadCharset(chsbuf, CFG->xlatlocalset); - if(chslev) { - level = msg->charsetlevel = chslev; - strcpy(msg->charset, chsbuf); - } + if(not gotmime) { + strcpy(chsbuf, (striinc("8859-1", ptr) or striinc("Latin1", ptr)) ? "LATIN-1" : ptr); + chslev = LoadCharset(chsbuf, CFG->xlatlocalset); + if(chslev) { + level = msg->charsetlevel = chslev; + strcpy(msg->charset, chsbuf); } } } else if(kludgetype == RFC_X_CHAR_ESC) { - if(getvalue) - if(not gotmime) - msg->charsetencoding |= GCHENC_MNE; + if(not gotmime) + msg->charsetencoding |= GCHENC_MNE; } if(keptr) *keptr = endchar; @@ -2535,10 +2537,10 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) { // Charset translate header fields if(header_recode) { - strxmimecpy(msg->realby, msg->realby, 0, sizeof(INam)); - strxmimecpy(msg->realto, msg->realto, 0, sizeof(INam)); - strxmimecpy(msg->by, msg->by, level, sizeof(INam)); - strxmimecpy(msg->to, msg->to, level, sizeof(INam)); + strxmimecpy(msg->realby, msg->realby, 0, sizeof(INam), true); + strxmimecpy(msg->realto, msg->realto, 0, sizeof(INam), true); + strxmimecpy(msg->by, msg->by, level, sizeof(INam), true); + strxmimecpy(msg->to, msg->to, level, sizeof(INam), true); if(not (msg->attr.frq() or msg->attr.att() or msg->attr.urq())) strxmimecpy(msg->re, msg->re, level, sizeof(ISub), true); diff --git a/golded3/gelmsg.cpp b/golded3/gelmsg.cpp index 6240ccc..78c11da 100644 --- a/golded3/gelmsg.cpp +++ b/golded3/gelmsg.cpp @@ -65,10 +65,10 @@ int Area::LoadHdr(GMsg* msg, ulong msgno, bool enable_recode) { msg->charsetlevel = LoadCharset(CFG->xlatcharset[table].imp, CFG->xlatcharset[table].exp); // Charset translate header fields - strxmimecpy(msg->realby, msg->realby, msg->charsetlevel, sizeof(INam)); - strxmimecpy(msg->realto, msg->realto, msg->charsetlevel, sizeof(INam)); - strxmimecpy(msg->by , msg->by , msg->charsetlevel, sizeof(INam)); - strxmimecpy(msg->to , msg->to , msg->charsetlevel, sizeof(INam)); + strxmimecpy(msg->realby, msg->realby, msg->charsetlevel, sizeof(INam), true); + strxmimecpy(msg->realto, msg->realto, msg->charsetlevel, sizeof(INam), true); + strxmimecpy(msg->by , msg->by , msg->charsetlevel, sizeof(INam), true); + strxmimecpy(msg->to , msg->to , msg->charsetlevel, sizeof(INam), true); if(not (msg->attr.frq() or msg->attr.att() or msg->attr.urq())) strxmimecpy(msg->re , msg->re , msg->charsetlevel, sizeof(ISub), true); diff --git a/golded3/gerand.cpp b/golded3/gerand.cpp index b6c8ce2..bc3ef49 100644 --- a/golded3/gerand.cpp +++ b/golded3/gerand.cpp @@ -38,6 +38,8 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* __file) { FILE* fp = fsopen(AddPath(CFG->goldpath, __file), "rb", CFG->sharemode); if(fp) { + setvbuf(fp, NULL, _IOFBF, 32000); + // Check if index exists or if it is older than the textfile const char* idxfile = AddPath(CFG->goldpath, indexfile); int idxexist = fexist(idxfile); @@ -47,9 +49,8 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* __file) { // Create index if one was missing if(not idxexist) { - FILE* fpi = fsopen(idxfile, "wb+", CFG->sharemode); + FILE* fpi = fsopen(idxfile, "wb", CFG->sharemode); if(fpi) { - setvbuf(fp, NULL, _IOFBF, 32000); setvbuf(fpi, NULL, _IOFBF, 16000); long fpos = 0; char buf[512]; @@ -64,6 +65,8 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* __file) { FILE* fpi = fsopen(idxfile, "rb", CFG->sharemode); if(fpi) { + setvbuf(fpi, NULL, _IOFBF, 16000); + // Get random line if there is at least one int _lines = (int)(fsize(fpi)/sizeof(long)); if(_lines > 0) { diff --git a/goldlib/gall/gkbdbase.cpp b/goldlib/gall/gkbdbase.cpp index 1980ed8..ba9994c 100644 --- a/goldlib/gall/gkbdbase.cpp +++ b/goldlib/gall/gkbdbase.cpp @@ -1211,7 +1211,7 @@ gkey kbxget_raw(int mode) { case VK_CAPITAL: case VK_NUMLOCK: case VK_SCROLL: - return (gkey)k; // Return empty key + break; case VK_NUMPAD0: case VK_NUMPAD1: @@ -1245,12 +1245,12 @@ gkey kbxget_raw(int mode) { // fall through default: if(ascii == '\x2e') { - return (gkey)ascii; + k = (gkey)ascii; } else { int kc = gkbd_nt2bios(inp); if(kc != -1) - return (gkey)kc; + k = (gkey)kc; } break; @@ -1264,10 +1264,11 @@ gkey kbxget_raw(int mode) { case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xef: case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xf4: case 0xf5: - if(ascii) - return (gkey)ascii; + k = (gkey)ascii; break; } + if(k != 0) + break; } else { // Discard other events diff --git a/goldlib/gall/gstrutil.cpp b/goldlib/gall/gstrutil.cpp index fb52934..69a6a1f 100644 --- a/goldlib/gall/gstrutil.cpp +++ b/goldlib/gall/gstrutil.cpp @@ -494,9 +494,9 @@ const char* strlword(const char* str) { *left = NUL; if(*str) { - strcpy(buf, str); + strxcpy(buf, str, sizeof(buf)); if(strtok(buf, " ") != NULL) { - strcpy(left, buf); + strxcpy(left, buf, sizeof(left)); } } return left; @@ -514,7 +514,7 @@ const char* strrword(const char* str) { *right = NUL; if(*str) { - strcpy(buf, str); + strxcpy(buf, str, sizeof(buf)); ptr = strtok(buf, " "); ptr2 = ptr; while(ptr != NULL) { @@ -522,7 +522,7 @@ const char* strrword(const char* str) { ptr = strtok(NULL, " "); } if(ptr2) { - strcpy(right, ptr2); + strxcpy(right, ptr2, sizeof(right)); } } return right; diff --git a/goldlib/gall/gvidinit.cpp b/goldlib/gall/gvidinit.cpp index 3294e9e..ff5defd 100644 --- a/goldlib/gall/gvidinit.cpp +++ b/goldlib/gall/gvidinit.cpp @@ -572,7 +572,7 @@ void GVid::detectinfo(GVidInfo* _info) { // Get video mode and number of rows and columns CONSOLE_SCREEN_BUFFER_INFO csbi; - GetConsoleScreenBufferInfo(gvid_hout, &csbi); + assert(GetConsoleScreenBufferInfo(gvid_hout, &csbi) != 0); _info->screen.mode = 0; _info->screen.rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; diff --git a/goldlib/gcfg/gxcrash.cpp b/goldlib/gcfg/gxcrash.cpp index acafe45..ad2e9d5 100644 --- a/goldlib/gcfg/gxcrash.cpp +++ b/goldlib/gcfg/gxcrash.cpp @@ -219,8 +219,8 @@ void gareafile::ReadCrashmail(char* tag) { strxmerge(tmp, 100, address, "@", domain, NULL); CfgAddress(tmp); } + fclose(fp); } - fclose(fp); }