Encoding fixes, Win95 kbd fix, boundary checking added

This commit is contained in:
Alexander S. Aganichev 2000-12-20 19:53:25 +00:00
parent 420527ccfe
commit fe6812d9a6
8 changed files with 87 additions and 73 deletions

View File

@ -12,6 +12,14 @@ ______________________________________________________________________
Notes for GoldED+ 1.1.5, December xx 2000 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 + If filenames specified without path and File Attach attribute is set
Attachpath automatically prepended to every filename. Attachpath automatically prepended to every filename.

View File

@ -2016,79 +2016,81 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
} }
if(kludgetype == FSC_I51) { if(kludgetype == FSC_I51) {
msg->i51 = true; msg->i51 = true;
if(getvalue) { // Convert FSC-0051.003 to FSC-0054.003
// Convert FSC-0051.003 to FSC-0054.003 strcpy(chsbuf, "LATIN-1");
strcpy(chsbuf, "LATIN-1"); chslev = LoadCharset(chsbuf, CFG->xlatlocalset);
chslev = LoadCharset(chsbuf, CFG->xlatlocalset); if(chslev) {
if(chslev) { level = msg->charsetlevel = chslev;
level = msg->charsetlevel = chslev; strcpy(msg->charset, chsbuf);
strcpy(msg->charset, chsbuf);
}
} }
} }
else if(kludgetype == FSC_CHARSET) { else if(kludgetype == FSC_CHARSET) {
if(getvalue) { *chsbuf = NUL;
*chsbuf = NUL; qpencoded = striinc("LATIN1QP", ptr) ? true : false;
qpencoded = striinc("LATIN1QP", ptr) ? true : false; strxcpy(chsbuf, qpencoded ? "LATIN-1" : ptr, sizeof(chsbuf));
strxcpy(chsbuf, qpencoded ? "LATIN-1" : ptr, sizeof(chsbuf)); // Workaround for buggy mailreaders which stores '_' in charset name
// Workaround for buggy mailreaders which stores '_' in charset name strchg(chsbuf,'_',' ');
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); chslev = LoadCharset(chsbuf, CFG->xlatlocalset);
if(chslev) { if(chslev) {
level = msg->charsetlevel = chslev; level = msg->charsetlevel = chslev;
strcpy(msg->charset, chsbuf); strcpy(msg->charset, chsbuf);
} }
if(*msg->charset == NUL)
strcpy(msg->charset, chsbuf);
gotmime = true;
} }
} if(check_multipart(ptr, keptr, boundary)) {
else if(kludgetype == RFC_CONTENT_TYPE) { gotmultipart = true;
if(getvalue) { gotmime = true;
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;
}
} }
} }
else if(kludgetype == RFC_CONTENT_TRANSFER_ENCODING) { else if(kludgetype == RFC_CONTENT_TRANSFER_ENCODING) {
if(getvalue) { if(striinc("quoted-printable", ptr)) {
if(striinc("quoted-printable", ptr)) { qpencoded = true;
qpencoded = true; msg->charsetencoding |= GCHENC_QP;
msg->charsetencoding |= GCHENC_QP; // ASA: What the stuff below for? I never saw such messages...
if(striinc("LATIN-1", msg->charset)) { if(striinc("LATIN-1", msg->charset)) {
strcpy(chsbuf, "LATIN1QP"); strcpy(chsbuf, "LATIN1QP");
chslev = LoadCharset("LATIN-1", CFG->xlatlocalset); chslev = LoadCharset("LATIN-1", CFG->xlatlocalset);
if(chslev) { if(chslev) {
level = msg->charsetlevel = chslev; level = msg->charsetlevel = chslev;
strcpy(msg->charset, chsbuf); strcpy(msg->charset, chsbuf);
}
} }
} }
} }
} }
else if(kludgetype == RFC_X_CHARSET) { else if(kludgetype == RFC_X_CHARSET) {
if(getvalue) { if(not gotmime) {
if(not gotmime) { strcpy(chsbuf, (striinc("8859-1", ptr) or striinc("Latin1", ptr)) ? "LATIN-1" : ptr);
strcpy(chsbuf, (striinc("8859-1", ptr) or striinc("Latin1", ptr)) ? "LATIN-1" : CFG->xlatlocalset); chslev = LoadCharset(chsbuf, CFG->xlatlocalset);
chslev = LoadCharset(chsbuf, CFG->xlatlocalset); if(chslev) {
if(chslev) { level = msg->charsetlevel = chslev;
level = msg->charsetlevel = chslev; strcpy(msg->charset, chsbuf);
strcpy(msg->charset, chsbuf);
}
} }
} }
} }
else if(kludgetype == RFC_X_CHAR_ESC) { else if(kludgetype == RFC_X_CHAR_ESC) {
if(getvalue) if(not gotmime)
if(not gotmime) msg->charsetencoding |= GCHENC_MNE;
msg->charsetencoding |= GCHENC_MNE;
} }
if(keptr) if(keptr)
*keptr = endchar; *keptr = endchar;
@ -2535,10 +2537,10 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
// Charset translate header fields // Charset translate header fields
if(header_recode) { if(header_recode) {
strxmimecpy(msg->realby, msg->realby, 0, sizeof(INam)); strxmimecpy(msg->realby, msg->realby, 0, sizeof(INam), true);
strxmimecpy(msg->realto, msg->realto, 0, sizeof(INam)); strxmimecpy(msg->realto, msg->realto, 0, sizeof(INam), true);
strxmimecpy(msg->by, msg->by, level, sizeof(INam)); strxmimecpy(msg->by, msg->by, level, sizeof(INam), true);
strxmimecpy(msg->to, msg->to, level, sizeof(INam)); strxmimecpy(msg->to, msg->to, level, sizeof(INam), true);
if(not (msg->attr.frq() or msg->attr.att() or msg->attr.urq())) if(not (msg->attr.frq() or msg->attr.att() or msg->attr.urq()))
strxmimecpy(msg->re, msg->re, level, sizeof(ISub), true); strxmimecpy(msg->re, msg->re, level, sizeof(ISub), true);

View File

@ -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); msg->charsetlevel = LoadCharset(CFG->xlatcharset[table].imp, CFG->xlatcharset[table].exp);
// Charset translate header fields // Charset translate header fields
strxmimecpy(msg->realby, msg->realby, msg->charsetlevel, sizeof(INam)); strxmimecpy(msg->realby, msg->realby, msg->charsetlevel, sizeof(INam), true);
strxmimecpy(msg->realto, msg->realto, msg->charsetlevel, sizeof(INam)); strxmimecpy(msg->realto, msg->realto, msg->charsetlevel, sizeof(INam), true);
strxmimecpy(msg->by , msg->by , msg->charsetlevel, sizeof(INam)); strxmimecpy(msg->by , msg->by , msg->charsetlevel, sizeof(INam), true);
strxmimecpy(msg->to , msg->to , msg->charsetlevel, sizeof(INam)); strxmimecpy(msg->to , msg->to , msg->charsetlevel, sizeof(INam), true);
if(not (msg->attr.frq() or msg->attr.att() or msg->attr.urq())) if(not (msg->attr.frq() or msg->attr.att() or msg->attr.urq()))
strxmimecpy(msg->re , msg->re , msg->charsetlevel, sizeof(ISub), true); strxmimecpy(msg->re , msg->re , msg->charsetlevel, sizeof(ISub), true);

View File

@ -38,6 +38,8 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* __file) {
FILE* fp = fsopen(AddPath(CFG->goldpath, __file), "rb", CFG->sharemode); FILE* fp = fsopen(AddPath(CFG->goldpath, __file), "rb", CFG->sharemode);
if(fp) { if(fp) {
setvbuf(fp, NULL, _IOFBF, 32000);
// Check if index exists or if it is older than the textfile // Check if index exists or if it is older than the textfile
const char* idxfile = AddPath(CFG->goldpath, indexfile); const char* idxfile = AddPath(CFG->goldpath, indexfile);
int idxexist = fexist(idxfile); int idxexist = fexist(idxfile);
@ -47,9 +49,8 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* __file) {
// Create index if one was missing // Create index if one was missing
if(not idxexist) { if(not idxexist) {
FILE* fpi = fsopen(idxfile, "wb+", CFG->sharemode); FILE* fpi = fsopen(idxfile, "wb", CFG->sharemode);
if(fpi) { if(fpi) {
setvbuf(fp, NULL, _IOFBF, 32000);
setvbuf(fpi, NULL, _IOFBF, 16000); setvbuf(fpi, NULL, _IOFBF, 16000);
long fpos = 0; long fpos = 0;
char buf[512]; char buf[512];
@ -64,6 +65,8 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* __file) {
FILE* fpi = fsopen(idxfile, "rb", CFG->sharemode); FILE* fpi = fsopen(idxfile, "rb", CFG->sharemode);
if(fpi) { if(fpi) {
setvbuf(fpi, NULL, _IOFBF, 16000);
// Get random line if there is at least one // Get random line if there is at least one
int _lines = (int)(fsize(fpi)/sizeof(long)); int _lines = (int)(fsize(fpi)/sizeof(long));
if(_lines > 0) { if(_lines > 0) {

View File

@ -1211,7 +1211,7 @@ gkey kbxget_raw(int mode) {
case VK_CAPITAL: case VK_CAPITAL:
case VK_NUMLOCK: case VK_NUMLOCK:
case VK_SCROLL: case VK_SCROLL:
return (gkey)k; // Return empty key break;
case VK_NUMPAD0: case VK_NUMPAD0:
case VK_NUMPAD1: case VK_NUMPAD1:
@ -1245,12 +1245,12 @@ gkey kbxget_raw(int mode) {
// fall through // fall through
default: default:
if(ascii == '\x2e') { if(ascii == '\x2e') {
return (gkey)ascii; k = (gkey)ascii;
} }
else { else {
int kc = gkbd_nt2bios(inp); int kc = gkbd_nt2bios(inp);
if(kc != -1) if(kc != -1)
return (gkey)kc; k = (gkey)kc;
} }
break; break;
@ -1264,10 +1264,11 @@ gkey kbxget_raw(int mode) {
case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed:
case 0xef: case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xef: case 0xf0: case 0xf1: case 0xf2: case 0xf3:
case 0xf4: case 0xf5: case 0xf4: case 0xf5:
if(ascii) k = (gkey)ascii;
return (gkey)ascii;
break; break;
} }
if(k != 0)
break;
} }
else { else {
// Discard other events // Discard other events

View File

@ -494,9 +494,9 @@ const char* strlword(const char* str) {
*left = NUL; *left = NUL;
if(*str) { if(*str) {
strcpy(buf, str); strxcpy(buf, str, sizeof(buf));
if(strtok(buf, " ") != NULL) { if(strtok(buf, " ") != NULL) {
strcpy(left, buf); strxcpy(left, buf, sizeof(left));
} }
} }
return left; return left;
@ -514,7 +514,7 @@ const char* strrword(const char* str) {
*right = NUL; *right = NUL;
if(*str) { if(*str) {
strcpy(buf, str); strxcpy(buf, str, sizeof(buf));
ptr = strtok(buf, " "); ptr = strtok(buf, " ");
ptr2 = ptr; ptr2 = ptr;
while(ptr != NULL) { while(ptr != NULL) {
@ -522,7 +522,7 @@ const char* strrword(const char* str) {
ptr = strtok(NULL, " "); ptr = strtok(NULL, " ");
} }
if(ptr2) { if(ptr2) {
strcpy(right, ptr2); strxcpy(right, ptr2, sizeof(right));
} }
} }
return right; return right;

View File

@ -572,7 +572,7 @@ void GVid::detectinfo(GVidInfo* _info) {
// Get video mode and number of rows and columns // Get video mode and number of rows and columns
CONSOLE_SCREEN_BUFFER_INFO csbi; CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(gvid_hout, &csbi); assert(GetConsoleScreenBufferInfo(gvid_hout, &csbi) != 0);
_info->screen.mode = 0; _info->screen.mode = 0;
_info->screen.rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; _info->screen.rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;

View File

@ -219,8 +219,8 @@ void gareafile::ReadCrashmail(char* tag) {
strxmerge(tmp, 100, address, "@", domain, NULL); strxmerge(tmp, 100, address, "@", domain, NULL);
CfgAddress(tmp); CfgAddress(tmp);
} }
fclose(fp);
} }
fclose(fp);
} }