pan-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pan-users] Multipart pic display


From: Per Hedeland
Subject: Re: [Pan-users] Multipart pic display
Date: Sun, 6 Aug 2006 05:18:45 +0200 (CEST)

Per Hedeland <address@hidden> wrote:
>
>I've noticed that for some pictures posted as multiple parts, pan will
>fail to display the complete picture - seems it only shows what is
>contained in the first part, with the rest black or occasionally
>containing garbled parts of other pictures (i.e. smells of uninitialized
>memory).
[snip]

Hm, the overwhelming response to that made me go looking for a fix
myself:-) - patch for 0.106 below. The problem was that the handling of
invalid uu lines was broken (the troublesome posts that I've come across
had an extra empty line between the article header and the uu stuff):
Since the gmime filter wants to see the "begin" line, it doesn't work to
create a new filter for each chunk-between-invalid-lines. Fixed by
having a "persistent" filter, which then needs to be attached to the
output stream instead of the input.

--Per

--- pan/usenet-utils/mime-utils.cc.ORIG Wed Jun 21 05:35:28 2006
+++ pan/usenet-utils/mime-utils.cc      Sun Aug  6 04:52:39 2006
@@ -396,6 +396,7 @@
   struct TempPart
   {
     GMimeStream * stream;
+    GMimeStream * filter_stream;
     char * filename;
     unsigned int valid_lines;
     EncType type;
@@ -410,7 +411,7 @@
     size_t y_size;
 
     TempPart (EncType intype=ENC_UU, char *infilename=0): stream(0),
-      filename(infilename), valid_lines(0), type(intype),
+      filter_stream(0), filename(infilename), valid_lines(0), type(intype),
       y_line_len(0), y_attach_size(0), y_part(0),
       y_offset_begin(0), y_offset_end(0),
       y_crc(0), y_pcrc(0), y_size(0) {}
@@ -418,6 +419,8 @@
     ~TempPart () {
       g_free (filename);
       g_object_unref (stream);
+      if (filter_stream)
+       g_object_unref (filter_stream);
     }
   };
 
@@ -445,21 +448,22 @@
 
   void apply_source_and_maybe_filter (TempPart * part, GMimeStream * s)
   {
-    if (!part->stream)
+    if (!part->stream) {
       part->stream = g_mime_stream_mem_new ();
-
-    if (part->type != ENC_PLAIN) {
-      GMimeStream * filter_stream = g_mime_stream_filter_new_with_stream (s);
-      GMimeFilter * filter = part->type == ENC_UU
-        ? g_mime_filter_basic_new_type (GMIME_FILTER_BASIC_UU_DEC)
-        : g_mime_filter_yenc_new (GMIME_FILTER_YENC_DIRECTION_DECODE);
-      g_mime_stream_filter_add (GMIME_STREAM_FILTER(filter_stream), filter);
-      g_object_unref (filter);
-      g_object_unref (s);
-      s = filter_stream;
+      if (part->type != ENC_PLAIN) {
+       part->filter_stream =
+         g_mime_stream_filter_new_with_stream (part->stream);
+       GMimeFilter * filter = part->type == ENC_UU
+         ? g_mime_filter_basic_new_type (GMIME_FILTER_BASIC_UU_DEC)
+         : g_mime_filter_yenc_new (GMIME_FILTER_YENC_DIRECTION_DECODE);
+       g_mime_stream_filter_add (GMIME_STREAM_FILTER(part->filter_stream),
+                                 filter);
+       g_object_unref (filter);
+      }
     }
 
-    g_mime_stream_write_to_stream (s, part->stream);
+    g_mime_stream_write_to_stream (s, part->type == ENC_PLAIN ?
+                                  part->stream : part->filter_stream);
     g_object_unref (s);
   }
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]