Patch to handle undeclared 8 bit characters
Thomas Wiegner <[email protected]>
| Newsgroups | gmane.network.slrn.user |
|---|---|
| Organization | Powered by Penguin |
| Message-ID | <20070611202856.GA17555@fliewatuet> |
Hi all,
I hope this is the right place, to send this.
I wrote a small patch to handle postings with undeclared 8 bit
characters in the Subject, Header and also undeclared 8 bit
characters in the body with a missing "Content-Type:" Header
(mostly created by MS Outlook Express).
When running slrn in an UTF-8 environment this will result in
displaying things like "Gr<FC><DF>e" instead of "Grüße".
With this patch you can set an variable in the .slrnrc to tell slrn
that it should assume this text to be encoded with the charset
defined by the "fallback_charset" variable, eg
| set fallback_charset iso-8859-1
All charsets known to the iconv function should be possible.
If the value is not set, slrn behaves like without the patch.
The latest slrn from cvs is needed (or at least the tarball which
debian ships as slrn_0.9.8.1pl2~cvs20070125 in its repositories).
Feedback is welcome, I'm not sure, if I forgot to consider some
dependencies from config.h, which of course will vary on systems
different from mine.
Cheers,
Thomas
<---------------- cut here --------------->
--- src_ori/mime.c 2007-01-26 21:38:23.000000000 +0100
+++ src/mime.c 2007-06-11 20:10:20.000000000 +0200
@@ -52,6 +52,7 @@
int Slrn_Use_Meta_Mail = 1;
int Slrn_Fold_Headers = 1;
char *Slrn_MetaMail_Cmd;
+char *Slrn_Fallback_Input_Charset = NULL;
#ifndef SLRNPULL_CODE
#define CONTENT_TYPE_TEXT 0x01
@@ -100,7 +101,15 @@
line = a->lines;
if (NULL == (line = find_header_line (a, "Content-Type:")))
+ {
+ if( Slrn_Fallback_Input_Charset != NULL)
+ {
+ a->mime.content_subtype = CONTENT_SUBTYPE_PLAIN;
+ a->mime.content_type = CONTENT_TYPE_TEXT;
+ a->mime.charset = slrn_safe_strnmalloc (Slrn_Fallback_Input_Charset, strlen(Slrn_Fallback_Input_Charset));
+ }
return 0;
+ }
b = slrn_skip_whitespace (line->buf + 13);
@@ -333,8 +342,20 @@
s= *s_ptr;
if (slrn_string_nonascii(s))
+ {
+ if(Slrn_Fallback_Input_Charset != NULL)
+ {
+ char *c;
+
+ c= slrn_convert_substring(s, 0, 0, Slrn_Display_Charset, Slrn_Fallback_Input_Charset, 0);
+ if(c != NULL)
+ {
+ slrn_free(*s_ptr);
+ *s_ptr=c;
+ }
+ }
return -1;
-
+ }
while (1)
{
while ((NULL != (s = slrn_strchr (s, '=')))
--- src_ori/mime.h 2006-08-03 13:39:21.000000000 +0200
+++ src/mime.h 2007-06-08 19:27:15.000000000 +0200
@@ -31,6 +31,6 @@
extern int Slrn_Fold_Headers;
extern int Slrn_Use_Meta_Mail;
extern char *Slrn_MetaMail_Cmd;
-
+extern char *Slrn_Fallback_Input_Charset;
#endif /* _SLRN_MIME_H */
--- src_ori/startup.c 2006-09-03 16:56:11.000000000 +0200
+++ src/startup.c 2007-06-08 19:30:02.000000000 +0200
@@ -742,6 +742,7 @@
#else
{"charset", NULL},
#endif
+ {"fallback_charset", &Slrn_Fallback_Input_Charset},
#ifndef VMS
{"sendmail_command", &Slrn_SendMail_Command},
#endif
<---------------- cut here --------------->
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/