Added more charset patches by Dmitry Komissaroff

This commit is contained in:
Michiel Broek 2005-02-14 19:57:19 +00:00
parent b75e36a3d6
commit f72749e915
5 changed files with 106 additions and 12 deletions

View File

@ -23,8 +23,14 @@ v0.71.2 16-Jan-2005
so that we later can decide to mark these messages auto deleted. so that we later can decide to mark these messages auto deleted.
mbnntp: mbnntp:
Does now send the right mime headers recognised by new clients. Does now send the right mime headers recognised by news clients.
Fixed compile problem with some compilers. Fixed compile problem with some compilers.
When sending the mime header with the charset used to the news
client, the original message charset is tried first, else the
area charset, else the users charset and if all failed, we send
the us-ascci charset as default.
More patches added from Dmitry Komissaroff to improve charset
support. Also improved msgid linking.
html: html:
Added batch file upload written by Russell Tiedt to the faq. Added batch file upload written by Russell Tiedt to the faq.

View File

@ -63,7 +63,7 @@ openport.o: ../config.h ../lib/mbselib.h ttyio.h openport.h
ttyio.o: ../config.h ../lib/mbselib.h ttyio.h ttyio.o: ../config.h ../lib/mbselib.h ttyio.h
auth.o: ../config.h ../lib/mbselib.h ../lib/users.h mbnntp.h auth.h auth.o: ../config.h ../lib/mbselib.h ../lib/users.h mbnntp.h auth.h
commands.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h ../lib/msgtext.h ../lib/mbsedb.h ttyio.h mbnntp.h rfc2ftn.h commands.h commands.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h ../lib/msgtext.h ../lib/mbsedb.h ttyio.h mbnntp.h rfc2ftn.h commands.h
rfc2ftn.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbinet.h ../lib/mbsedb.h ../lib/msg.h ../lib/msgtext.h mkftnhdr.h hash.h msgflags.h rfc2ftn.h rfc2ftn.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbinet.h ../lib/mbsedb.h ../lib/msg.h ../lib/msgtext.h mkftnhdr.h hash.h msgflags.h rfc2ftn.h commands.h
hash.o: ../config.h ../lib/mbselib.h hash.h lhash.h hash.o: ../config.h ../lib/mbselib.h hash.h lhash.h
lhash.o: ../config.h ../lib/mbselib.h lhash.h lhash.o: ../config.h ../lib/mbselib.h lhash.h
msgflags.o: ../config.h ../lib/mbselib.h msgflags.h msgflags.o: ../config.h ../lib/mbselib.h msgflags.h

View File

@ -50,7 +50,6 @@ extern unsigned long rcvdbytes;
extern char *ttystat[]; extern char *ttystat[];
void send_xlat(char *); void send_xlat(char *);
char *make_msgid(char *);
static CharsetAlias *charset_alias_list; static CharsetAlias *charset_alias_list;
static CharsetTable *charset_table_list; static CharsetTable *charset_table_list;
@ -245,10 +244,18 @@ void command_abhs(char *buf)
/* /*
* Send RFC 2045 Multipurpose Internet Mail Extensions (MIME) header. * Send RFC 2045 Multipurpose Internet Mail Extensions (MIME) header.
* Order is: 1. Charset defined in the FTN message
* 2. Charset of the message area
* 3. Charset of the user
* 4. Default us-ascii.
*/ */
send_nntp("MIME-Version: 1.0"); send_nntp("MIME-Version: 1.0");
if (charset) { if (charset) {
send_nntp("Content-Type: text/plain; charset=%s", charset_alias_rfc(charset)); send_nntp("Content-Type: text/plain; charset=%s", charset_alias_rfc(charset));
} else if (msgs.Charset != FTNC_NONE) {
send_nntp("Content-Type: text/plain; charset=%s", getrfcchrs(msgs.Charset));
} else if (usercharset != FTNC_NONE) {
send_nntp("Content-Type: text/plain; charset=%s", getrfcchrs(usercharset));
} else { } else {
send_nntp("Content-Type: text/plain; charset=us-ascii; format=fixed"); send_nntp("Content-Type: text/plain; charset=us-ascii; format=fixed");
} }

View File

@ -5,6 +5,8 @@
#ifndef USE_NEWSGATE #ifndef USE_NEWSGATE
char *getrfcchrs(int);
char *make_msgid(char *);
void command_abhs(char *); /* ARTICLE/BODY/HEADER/STAT */ void command_abhs(char *); /* ARTICLE/BODY/HEADER/STAT */
void command_group(char *); /* GROUP */ void command_group(char *); /* GROUP */
void command_list(char *); /* LIST */ void command_list(char *); /* LIST */

View File

@ -39,6 +39,7 @@
#include "hash.h" #include "hash.h"
#include "msgflags.h" #include "msgflags.h"
#include "rfc2ftn.h" #include "rfc2ftn.h"
#include "commands.h"
#ifndef USE_NEWSGATE #ifndef USE_NEWSGATE
@ -66,7 +67,7 @@ static int removereturnto;
extern char *replyaddr; extern char *replyaddr;
extern int do_mailout; extern int do_mailout;
extern int grecno; extern int grecno;
extern char currentgroup[];
/* /*
* Internal functions * Internal functions
@ -78,15 +79,22 @@ int needputrfc(rfcmsg *, int);
int charwrite(char *, FILE *); int charwrite(char *, FILE *);
int charwrite(char *s, FILE *fp) int charwrite(char *s, FILE *fp)
{ {
if ((strlen(s) >= 3) && (strncmp(s,"---",3) == 0) && (s[3] != '-')) { char *o;
putc('-',fp);
putc(' ',fp); if ((strlen(s) >= 3) && (strncmp(s,"---",3) == 0) && (s[3] != '-')) {
putc('-',fp);
putc(' ',fp);
}
while (*s) {
o=s;
if (s[0] &0x080) {
o=charset_map_c(s[0],0);
} }
while (*s) { // putc(*s, fp);
putc(*s, fp); putc (*o,fp);
s++; s++;
} }
return 0; return 0;
} }
@ -113,6 +121,49 @@ int kludgewrite(char *s, FILE *fp)
} }
int findorigmsg(char *msgid, char *o)
{
unsigned long i, start, end;
char *gen2;
if (msgid == NULL) {
return 0;
}
if (!Msg_Open(msgs.Base)) {
return 0;
}
Msg_Number();
Msg_Highest();
Msg_Lowest();
if (MsgBase.Open == FALSE) {
Syslog('-', "Base closed");
return 0;
}
strcpy(currentgroup,msgs.Newsgroup);
start = MsgBase.Lowest;
end = MsgBase.Highest;
gen2 = calloc(strlen(msgid)+1,sizeof(char));
strcpy(gen2, strchr(msgid,'<'));
for (i = start; i <= end; i++) {
if (Msg_ReadHeader(i)) {
if (strncmp(gen2,make_msgid(Msg.Msgid),strlen(gen2)-1) == 0) {
Syslog('m',"Found msgid: %s",make_msgid(Msg.Msgid));
// realloc(o,(strlen(Msg.Msgid)+1)* sizeof(char));
strcpy(o,Msg.Msgid);
free(gen2);
return 1;
}
}
}
free(gen2);
return 0;
}
/* /*
* Input a RFC news message. * Input a RFC news message.
@ -131,8 +182,10 @@ int rfc2ftn(FILE *fp)
int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders; int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders;
time_t Now; time_t Now;
struct tm *l_date; struct tm *l_date;
char *charset = NULL, *tq;
temp = calloc(4097, sizeof(char)); temp = calloc(4097, sizeof(char));
charset = calloc(50,sizeof(char));
Syslog('m', "Entering rfc2ftn"); Syslog('m', "Entering rfc2ftn");
rewind(fp); rewind(fp);
msg = parsrfc(fp); msg = parsrfc(fp);
@ -160,6 +213,16 @@ int rfc2ftn(FILE *fp)
if ((p = hdr((char *)"References",msg))) { if ((p = hdr((char *)"References",msg))) {
p = strrchr(p,' '); p = strrchr(p,' ');
ftnmsgid(p,&fmsg->reply_a, &fmsg->reply_n,fmsg->area); ftnmsgid(p,&fmsg->reply_a, &fmsg->reply_n,fmsg->area);
//Griffin
fmsg->reply_s=calloc(256,sizeof(char));
findorigmsg(p,fmsg->reply_s);
fmsg->to->name=calloc(strlen(Msg.From)+1,sizeof(char));
strcpy(fmsg->to->name,Msg.From);
Syslog('m', "fmsg to-name %s",fmsg->to->name);
Syslog('m', "reply_s %s",fmsg->reply_s);
if (!chkftnmsgid(p)) { if (!chkftnmsgid(p)) {
hash_update_s(&fmsg->reply_n, fmsg->area); hash_update_s(&fmsg->reply_n, fmsg->area);
} }
@ -170,6 +233,8 @@ int rfc2ftn(FILE *fp)
} }
} }
chkftnmsgid(hdr((char *)"Message-ID",msg)); // ?? chkftnmsgid(hdr((char *)"Message-ID",msg)); // ??
removemime = FALSE; removemime = FALSE;
removemsgid = FALSE; removemsgid = FALSE;
@ -197,8 +262,21 @@ int rfc2ftn(FILE *fp)
removemime = TRUE; /* no need in MIME headers */ removemime = TRUE; /* no need in MIME headers */
Syslog('m', "removemime=%s", removemime ? "True":"False"); Syslog('m', "removemime=%s", removemime ? "True":"False");
} }
tq=calloc(100,sizeof(char));
memset(tq,0,100*sizeof(char));
strcpy(charset,"iso-8859-1");
strcpy(tq,strstr(p,"charset=")+8);
Syslog('m', "tq: %s|", tq);
if (tq!=NULL) {
strcpy(charset,tq);
charset[strlen(charset)-1]='\0';
}
Syslog('m', "charset: %s|", charset);
free(tq);
} }
charset_set_in_out(charset,getrfcchrs(msgs.Charset));
if ((p = hdr((char *)"Message-ID",msg))) { if ((p = hdr((char *)"Message-ID",msg))) {
if (!removemsgid) if (!removemsgid)
removemsgid = chkftnmsgid(p); removemsgid = chkftnmsgid(p);
@ -706,6 +784,7 @@ int rfc2ftn(FILE *fp)
fclose(ofp); fclose(ofp);
} while (needsplit); } while (needsplit);
free(temp); free(temp);
free(charset);
tidyrfc(msg); tidyrfc(msg);
tidy_ftnmsg(fmsg); tidy_ftnmsg(fmsg);
UpdateMsgs(); UpdateMsgs();