Updated charset definitions and mime headers

This commit is contained in:
Michiel Broek 2005-01-26 22:33:09 +00:00
parent a8bb84338a
commit 42238e6f29
4 changed files with 70 additions and 33 deletions

View File

@ -3,12 +3,17 @@ $Id$
v0.71.2 16-Jan-2005 v0.71.2 16-Jan-2005
charset:
Changed rfc-2045 name x-mac to mac. Changed x-ibmpc to cp437.
This allows rfc mime headers to show official names.
mbcico: mbcico:
Added protection during binkp receive for zero bytes compressed Added protection during binkp receive for zero bytes compressed
data frames, this will case uncompress error -5 because zero data frames, this will case uncompress error -5 because zero
bytes can't be compressed ar all. bytes can't be compressed ar all.
mbnntp: mbnntp:
Does now send the right mime headers recognised by new clients.
Fixed compile problem with some compilers. Fixed compile problem with some compilers.

View File

@ -19,8 +19,8 @@
# #
# IN-SET/OUT-SET: us-ascii (FSC-0054: ASCII, VT100) # IN-SET/OUT-SET: us-ascii (FSC-0054: ASCII, VT100)
# iso-8859-1 (FSC-0054: LATIN-1, AMIGA) # iso-8859-1 (FSC-0054: LATIN-1, AMIGA)
# x-ibmpc (FSC-0054: IBMPC, PC-8) # cp437 (FSC-0054: IBMPC, PC-8) (Was called x-ibmpc)
# x-mac (FSC-0054: MAC) # mac (FSC-0054: MAC)
# koir-8 (KOIR-8) # koir-8 (KOIR-8)
# x-alt (ALT) # x-alt (ALT)
# ... # ...
@ -56,10 +56,9 @@ alias ascii us-ascii
alias vt100 us-ascii alias vt100 us-ascii
alias latin-1 iso-8859-1 alias latin-1 iso-8859-1
alias amiga iso-8859-1 alias amiga iso-8859-1
alias ibmpc x-ibmpc alias ibmpc cp437
alias pc-8 x-ibmpc alias pc-8 cp437
alias cp437 x-ibmpc alias mac mac
alias mac x-mac
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
@ -73,12 +72,12 @@ table us-ascii iso-8859-1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table us-ascii x-ibmpc table us-ascii cp437
# nothing special to map # nothing special to map
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table us-ascii x-mac table us-ascii mac
# nothing special to map # nothing special to map
@ -252,7 +251,7 @@ map 1:1-noctrl
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table iso-8859-1 x-ibmpc table iso-8859-1 cp437
map \x80 ? map \x80 ?
map \x81 ? map \x81 ?
map \x82 ? map \x82 ?
@ -384,7 +383,7 @@ map \xFF \x98
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table iso-8859-1 x-mac table iso-8859-1 mac
map \x80 ? map \x80 ?
map \x81 ? map \x81 ?
map \x82 ? map \x82 ?
@ -516,7 +515,7 @@ map \xFF \xD7
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table x-ibmpc us-ascii table cp437 us-ascii
map \x80 C map \x80 C
map \x81 u e map \x81 u e
map \x82 e map \x82 e
@ -648,7 +647,7 @@ map \xFF \x20
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table x-ibmpc iso-8859-1 table cp437 iso-8859-1
map \x80 \xC7 map \x80 \xC7
map \x81 \xFC map \x81 \xFC
map \x82 \xE9 map \x82 \xE9
@ -780,12 +779,12 @@ map \xFF \x20
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table x-ibmpc x-ibmpc table cp437 cp437
# nothing special to map # nothing special to map
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table x-ibmpc x-mac table cp437 mac
map \x80 \x82 map \x80 \x82
map \x81 \x9F map \x81 \x9F
map \x82 \x8E map \x82 \x8E
@ -917,7 +916,7 @@ map \xFF \x20
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table x-mac us-ascii table mac us-ascii
map \x80 A e map \x80 A e
map \x81 A map \x81 A
map \x82 C map \x82 C
@ -1049,7 +1048,7 @@ map \xFF ?
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table x-mac iso-8859-1 table mac iso-8859-1
map \x80 \xC4 map \x80 \xC4
map \x81 \xC5 map \x81 \xC5
map \x82 \xC7 map \x82 \xC7
@ -1181,7 +1180,7 @@ map \xFF ?
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table x-mac x-ibmpc table mac cp437
map \x80 \x8E map \x80 \x8E
map \x81 \x8F map \x81 \x8F
map \x82 \x80 map \x82 \x80
@ -1313,7 +1312,7 @@ map \xFF v
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
table x-mac x-mac table mac mac
# nothing special to map # nothing special to map

View File

@ -842,7 +842,7 @@ map \xFF \xEF
# Channel map for translation CP866 codes to MAC codes # Channel map for translation CP866 codes to MAC codes
# (Russian language) # (Russian language)
# #
table cp866 x-mac table cp866 mac
map \x80 \x80 map \x80 \x80
map \x81 \x81 map \x81 \x81
map \x82 \x82 map \x82 \x82
@ -979,7 +979,7 @@ map \xFF \xCA
# Due to fidonet wieredness, capital Russian EN translates to # Due to fidonet wieredness, capital Russian EN translates to
# latin 'H'. # latin 'H'.
# #
table x-mac cp866 table mac cp866
map \x80 \x80 map \x80 \x80
map \x81 \x81 map \x81 \x81
map \x82 \x82 map \x82 \x82

View File

@ -52,6 +52,8 @@ extern char *ttystat[];
void send_xlat(char *); void send_xlat(char *);
char *make_msgid(char *); char *make_msgid(char *);
static CharsetAlias *charset_alias_list;
static CharsetTable *charset_table_list;
#define POST_MAXSIZE 10000 #define POST_MAXSIZE 10000
@ -134,9 +136,9 @@ char *getrfcchrs(int val)
*/ */
void command_abhs(char *buf) void command_abhs(char *buf)
{ {
char *p, *cmd, *opt, *subj; char *p, *cmd, *opt, *subj, *charset = NULL;
unsigned long art = 0L; unsigned long art = 0L;
int found; int i, found;
Syslog('+', "%s", buf); Syslog('+', "%s", buf);
cmd = strtok(buf, " \0"); cmd = strtok(buf, " \0");
@ -194,12 +196,6 @@ void command_abhs(char *buf)
return; return;
} }
/*
* Setup a charset translation
*/
charset_set_in_out(getrfcchrs(msgs.Charset),getrfcchrs(usercharset));
if (Msg_Read(art, 75)) { if (Msg_Read(art, 75)) {
if (strcasecmp(cmd, "ARTICLE") == 0) if (strcasecmp(cmd, "ARTICLE") == 0)
@ -209,6 +205,32 @@ void command_abhs(char *buf)
if (strcasecmp(cmd, "BODY") == 0) if (strcasecmp(cmd, "BODY") == 0)
send_nntp("222 %ld %s Article retrieved - Body follows", art, make_msgid(Msg.Msgid)); send_nntp("222 %ld %s Article retrieved - Body follows", art, make_msgid(Msg.Msgid));
/*
* Find out the charset used in the Fido side of the message
*/
if ((p = (char *)MsgText_First()) != NULL) {
do {
if (strncmp(p, (char *)"\001CHRS: ", 7) == 0) {
charset = xstrcpy(p + 7);
} else if (strncmp(p, "\001CHARSET: ", 10) == 0) {
charset = xstrcpy(p + 10);
}
} while ((p = (char *)MsgText_Next()) != NULL);
}
if (charset) {
if ((charset_alias_list == NULL) || (charset_table_list == NULL))
charset_read_bin();
for (i = 0; i < strlen(charset); i++) {
if (charset[i] == ' ') {
charset[i] = '\0';
break;
}
}
}
// We don't do translation to the users charset, the news reader must do that.
// charset_set_in_out(getrfcchrs(msgs.Charset),getrfcchrs(usercharset));
if ((strcasecmp(cmd, "ARTICLE") == 0) || (strcasecmp(cmd, "HEAD") == 0)) { if ((strcasecmp(cmd, "ARTICLE") == 0) || (strcasecmp(cmd, "HEAD") == 0)) {
send_nntp("Path: MBNNTP!not-for-mail"); send_nntp("Path: MBNNTP!not-for-mail");
@ -220,13 +242,24 @@ void command_abhs(char *buf)
send_nntp("Message-ID: %s", make_msgid(Msg.Msgid)); send_nntp("Message-ID: %s", make_msgid(Msg.Msgid));
if (strlen(Msg.Replyid)) if (strlen(Msg.Replyid))
send_nntp("References: %s", make_msgid(Msg.Replyid)); send_nntp("References: %s", make_msgid(Msg.Replyid));
/*
* Send RFC 2045 Multipurpose Internet Mail Extensions (MIME) header.
*/
send_nntp("MIME-Version: 1.0");
if (charset) {
send_nntp("Content-Type: text/plain; charset=%s", charset_alias_rfc(charset));
} else {
send_nntp("Content-Type: text/plain; charset=us-ascii; format=fixed");
}
send_nntp("Content-Transfer-Encoding: 8bit");
send_nntp("X-FTN-From: %s <%s>", Msg.From, Msg.FromAddress); send_nntp("X-FTN-From: %s <%s>", Msg.From, Msg.FromAddress);
if (strlen(Msg.To)) if (strlen(Msg.To))
send_nntp("X-FTN-To: %s", Msg.To); send_nntp("X-FTN-To: %s", Msg.To);
if ((p = (char *)MsgText_First()) != NULL) { if ((p = (char *)MsgText_First()) != NULL) {
do { do {
if ((p[0] == '\001') || (!strncmp(p, "SEEN-BY:", 8)) || (!strncmp(p, "AREA:", 5))) { if ((p[0] == '\001') || (!strncmp(p, "SEEN-BY:", 8)) || (!strncmp(p, "AREA:", 5))) {
Syslog('n', "%s", printablec(p, 0));
if (p[0] == '\001') { if (p[0] == '\001') {
send_nntp("X-FTN-%s", p+1); send_nntp("X-FTN-%s", p+1);
} else { } else {
@ -235,12 +268,12 @@ void command_abhs(char *buf)
} }
} while ((p = (char *)MsgText_Next()) != NULL); } while ((p = (char *)MsgText_Next()) != NULL);
} }
send_nntp("MIME-Version: 1.0");
send_nntp("Content-Type: text/plain; charset=%s; format=fixed", getrfcchrs(usercharset));
send_nntp("Content-Transfer-Encoding: 8bit");
} }
if (charset)
free(charset);
charset = NULL;
if (strcasecmp(cmd, "ARTICLE") == 0) if (strcasecmp(cmd, "ARTICLE") == 0)
send_nntp(""); send_nntp("");