Article View: news.software.readers
Article #209001Re: {slrn} build 234: 2 small probs
From: Thomas Wiegner
Date: Fri, 19 Oct 2007 15:55
Date: Fri, 19 Oct 2007 15:55
154 lines
5192 bytes
5192 bytes
On Fri, 19 Oct 2007, andrew <andrew@ilium.invalid> wrote:
>> No problem. Change:
>> #v+
>>
>> /* skip header lines */
>> while ((line != NULL)
>> && (line->flags & HEADER_LINE))
>> line=line->next;
>>
>> #v-
>> to
>> #v+
>>
>> /* skip header lines */
>> if (0) while ((line != NULL)
>> && (line->flags & HEADER_LINE))
>> line=line->next;
>>
>> #v-
>
> Done. But display remained as before. If the message has not appeared
> on your server yet the head is below:
>
> Newsgroups: rec.arts.books.tolkien
> Subject: Re: test
> Date: Thu, 18 Oct 2007 21:04:43 +0200
> Lines: 12
> Message-ID: <5npp2lFi2m6sU1@mid.individual.net>
> References: <op.t0bqjdjx0orlwa@emachine.home>
><slrnfhb6p5.2vn.andrew@ilium.inval
> Reply-To: "<D6>jevind L<E5>ng" <bredband.net@ojevind.lang>
the problem is, that slrn does the header decoding before the
guess_unknown_charset routine starts to guess the charset and
the header decoding is in a somewhat other matter.
On the other hand you can't be sure that the wrongly encoded headers are
in the same charset like the body. Or it can happen that only header is
encoded bad and body encoding is OK, like e.g. Forte-Agent does.
This patch should help:
#v+
Index: charset.c
===================================================================
--- charset.c (revision 235)
+++ charset.c (working copy)
@@ -73,11 +73,13 @@
/* returns 1 if *str contains chars not in us-ascii, 0 else */
int slrn_string_nonascii(char *str)
{
+ int pos=0;
while(*str != '\0')
{
if (*str & 0x80)
- return 1;
+ return pos;
str++;
+ pos++;
}
return 0;
}
Index: mime.c
===================================================================
--- mime.c (revision 235)
+++ mime.c (working copy)
@@ -345,6 +345,7 @@
unsigned int count;
unsigned int len;
int keep_nl = 0;
+ int offset;
count = 0;
after_whitespace = NULL;
@@ -352,8 +353,33 @@
charset = NULL;
s= *s_ptr;
- if (slrn_string_nonascii(s))
- return -1;
+ if ((offset = slrn_string_nonascii(s)))
+ {
+ /* Only ascii is allowed in headers, if we find unencoded 8 bit chars
+ * convert them with the fallback charset. */
+ char *c;
+ char *charset;
+ char *smax;
+ unsigned int nconsumed;
+ SLwchar_Type wch;
+
+ /* First see if it looks like UTF-8 */
+ smax = s + strlen(s);
+ if (NULL != SLutf8_decode ((unsigned char*)(s+offset), (unsigned char*)smax, &wch, &nconsumed))
+ {
+ charset = "UTF-8";
+ }
+ else
+ {
+ charset = "iso-8859-1";
+ }
+ c= slrn_convert_substring(s, 0, strlen(s), Slrn_Display_Charset, charset, 0);
+ if(c != NULL)
+ {
+ slrn_free(*s_ptr);
+ *s_ptr=c;
+ }
+ }
while (1)
{
@@ -945,7 +971,6 @@
a->mime.was_parsed = 1; /* or will be */
- rfc1522_decode_headers (a);
/* Is there a reason to use the following line? */
/* if (NULL == find_header_line (a, "Mime-Version:")) return;*/
@@ -956,7 +981,12 @@
a->mime.needs_metamail = 1;
return 0;
}
+ if(a->mime.charset == NULL)
+ if (NULL == (a->mime.charset = guess_unknown_charset (a)))
+ return -1;
+ rfc1522_decode_headers (a);
+
switch (parse_content_transfer_encoding_line (a))
{
case ENCODED_RAW:
@@ -982,15 +1012,8 @@
a->mime.needs_metamail = 1;
return 0;
}
-
+
if ((a->mime.needs_metamail == 0) &&
- (a->mime.charset == NULL))
- {
- if (NULL == (a->mime.charset = guess_unknown_charset (a)))
- return -1;
- }
-
- if ((a->mime.needs_metamail == 0) &&
(slrn_case_strncmp("us-ascii",
a->mime.charset,8) != 0) &&
(slrn_case_strcmp(Slrn_Display_Charset,
#v-
Cheers,
Thomas
Technical Details
Message-ID:
<ak0nu4-p4b.ln1@wiegner.user.individual.de>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news1.uni-leipzig.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mailReferences:
<slrnfhfm48.36g.andrew@ilium.invalid> <slrnfhftrn.uoc.jed@aluche.mit.edu> <slrnfhfvos.a06.andrew@ilium.invalid> <slrnfhg0ve.gb8.andrew@ilium.invalid> <slrnfhg1n3.1ps.jed@aluche.mit.edu> <slrnfhg2jd.mj9.andrew@ilium.invalid>Show Full Headers
Complete Article Headers
Message-ID: <ak0nu4-p4b.ln1@wiegner.user.individual.de>
Subject: Re: {slrn} build 234: 2 small probs
Date: Fri, 19 Oct 2007 17:55:22 +0200
From: Thomas Wiegner <wiegner@gmx.de>
References: <slrnfhfm48.36g.andrew@ilium.invalid> <slrnfhftrn.uoc.jed@aluche.mit.edu> <slrnfhfvos.a06.andrew@ilium.invalid> <slrnfhg0ve.gb8.andrew@ilium.invalid> <slrnfhg1n3.1ps.jed@aluche.mit.edu> <slrnfhg2jd.mj9.andrew@ilium.invalid>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news1.uni-leipzig.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
Newsgroups: news.software.readers
Lines: 154
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: individual.net GiqTi7QYVqZlBLPw2YKi7Q/NNhG8a3K7LZaoxcFfbQed+DHOQ=
X-Orig-Path: wiegner.user.individual.de!news
Cancel-Lock: sha1:tgjb1qGg2VO3R14YTZFAZpBEPvA=
User-Agent: slrn/0.9.8.1pl2.1 (Linux)