Re: slrn hangs on X-Face header - Patch

Thomas Wiegner <[email protected]>
Newsgroups gmane.network.slrn.user
Organization Powered by Penguin
Message-ID <20070808181943.GA13628@fliewatuet>
Hi Folks,

nice to hear the patch works. I improved the patch a little bit, it
now works different for headers and bodies.

slrn can runs into problems if there are qp
encoded newlines like =0A or tabs =09.

This patch throws away these characters if they occur in the header 
and splits them into separate lines according to slrns internal
structure for handling article lines.

So articles like this one 
<http://groups.google.com/group/mozilla.dev.extensions/msg/53b48c42793b2070?dmode=source>
will be displayed correctly.

Cheers,

 Thomas

--- src_qp/mime.c	2007-08-08 19:33:06.000000000 +0200
+++ src_test/mime.c	2007-08-08 20:10:01.000000000 +0200
@@ -300,10 +300,10 @@
 static char *decode_quoted_printable (char *dest,/*{{{*/
 				      char *src, char *srcmax,
 				      int treat_underscore_as_space,
-				      int strip_8bit)
+				      int keep_nl_tab)
 {
    char *allowed_in_qp = "0123456789ABCDEFabcdef";
-   unsigned char ch, mask = 0x0;
+   unsigned char ch;
 /*
 #ifndef SLRNPULL_CODE
    if (strip_8bit && (NULL == Char_Set))
@@ -319,8 +319,11 @@
 	    && (NULL != slrn_strchr (allowed_in_qp, src[1])))
 	  {
 	     ch = (16 * HEX(src[0])) + HEX(src[1]);
-	     if (ch & mask) ch = '?';
-	     *dest++ = (char) ch;
+             /* remove nl and tab from line if wanted */
+             if(keep_nl_tab || (ch != 0x0a && ch != 0x09))
+             {
+	       *dest++ = (char) ch;
+             }
 	     src += 2;
 	  }
 	else if ((ch == '_') && treat_underscore_as_space)
@@ -936,6 +939,49 @@
 }
 /*}}}*/
 
+int split_qp_lines(Slrn_Article_Type *a)/*{{{*/
+{
+   struct Slrn_Article_Line_Type *line, *new_line;
+   char   *qp_nl, *tmp_buf;
+
+   line=a->lines;
+
+   /* skip header lines */
+   while((line->flags & HEADER_LINE) == 0)
+   {
+     line=line->next;
+   }
+
+   while(line != NULL)
+   {
+       qp_nl = slrn_strchr((unsigned char*)line->buf, 0x0A);
+       /* if there is a newline inside a Slrn_Article_Line_Type->buf split this line into two */
+       if(qp_nl != NULL)
+       {
+           *qp_nl = 0;
+
+           new_line=(Slrn_Article_Line_Type *) slrn_malloc(sizeof(Slrn_Article_Line_Type),1,1);
+           new_line->buf=slrn_safe_strmalloc(qp_nl+1);
+
+           tmp_buf=slrn_safe_strmalloc((unsigned char*)line->buf);
+           slrn_free((unsigned char*)line->buf);
+           line->buf=tmp_buf;
+
+           new_line->next   = line->next;
+           new_line->prev   = line;
+           if(line->next != NULL)
+           {
+             line->next->prev = new_line;
+           }
+           line->next       = new_line;
+
+       }
+       line=line->next;
+   }
+}
+/*}}}*/
+
+
 int slrn_mime_process_article (Slrn_Article_Type *a)/*{{{*/
 {
    if ((a == NULL) || (a->mime.was_parsed))
@@ -979,6 +1025,7 @@
 	
       case ENCODED_QUOTED:
 	decode_mime_quoted_printable (a);
+        split_qp_lines(a);
 	break;
 	
       default:

-- 
slrn charset patches: http://www.foory.de/thw/slrn/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.