[pan2/testing: 137/279] fixed segfault in encoder.cc



commit 39dc62d4103292ba5fd8d0fc1967e34c8f7ff5f3
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Wed Jun 29 17:59:32 2011 +0200

    fixed segfault in encoder.cc

 pan/gui/post-ui.cc                |    8 ++++++--
 pan/tasks/encoder.cc              |    8 ++++----
 pan/usenet-utils/message-check.cc |    3 ++-
 3 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 4343616..caddaf9 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -1408,7 +1408,7 @@ PostUI :: new_message_from_ui (Mode mode)
   if (mode==POSTING && _prefs.get_flag (USER_AGENT_PREFS_KEY, true))
     g_mime_object_set_header ((GMimeObject *) msg, "User-Agent", get_user_agent());
 
-  // Message-ID
+  // Message-ID for single text-only posts
   if (mode==POSTING && _prefs.get_flag (MESSAGE_ID_PREFS_KEY, false)) {
     const std::string message_id = !profile.fqdn.empty()
       ? GNKSA::generate_message_id (profile.fqdn)
@@ -1432,7 +1432,11 @@ PostUI :: new_message_from_ui (Mode mode)
   GMimeDataWrapper * content_object = g_mime_data_wrapper_new_with_stream (stream, GMIME_CONTENT_ENCODING_DEFAULT);
   g_object_unref (stream);
   GMimePart * part = g_mime_part_new ();
-  pch = g_strdup_printf ("text/plain; charset=%s", charset.c_str());
+  if (_file_queue_empty)
+    pch = g_strdup_printf ("text/plain; charset=%s", charset.c_str());
+  else
+    // http://tools.ietf.org/html/rfc2046#section-5.1.3
+    pch = g_strdup_printf ("multipart/mixed; charset=%s", charset.c_str());
 
   GMimeContentType * type = g_mime_content_type_new_from_string (pch);
   g_free (pch);
diff --git a/pan/tasks/encoder.cc b/pan/tasks/encoder.cc
index 04c3892..8c9446b 100644
--- a/pan/tasks/encoder.cc
+++ b/pan/tasks/encoder.cc
@@ -102,7 +102,7 @@ Encoder :: do_work()
   struct stat sb;
   std::string s;
   FILE* outfile, * infile ;
-  PartBatch batch;
+//  PartBatch batch;
   char cachename[4096];
   FILE * fp ;
   Article* tmp = article;
@@ -117,7 +117,7 @@ Encoder :: do_work()
     UUSetMsgCallback (this, uu_log);
     UUSetBusyCallback (this, uu_busy_poll, 200);
 
-    batch.init(StringView(basename), needed->size(), 0);
+//    batch.init(StringView(basename), needed->size(), 0);
 
     /* build real subject line for article*/
     tmp->subject = subject;
@@ -170,7 +170,7 @@ _no_encode:
       it->second.cachename = cachename;
       it->second.bytes  = sb.st_size;
       task->_all_bytes += sb.st_size;
-      batch.add_part(cnt, StringView(it->second.mid), sb.st_size);
+      tmp->add_part(cnt, StringView(it->second.mid), sb.st_size);
       if (res != UURET_CONT) break;
     }
 
@@ -186,7 +186,7 @@ _no_encode:
       log_errors.push_back(buf); // log error
     } else
     { // prepare article for upload list
-      tmp->set_parts(batch);
+//      tmp->set_parts(batch);
       task->_upload_list.push_back(tmp);
     }
   UUCleanUp ();
diff --git a/pan/usenet-utils/message-check.cc b/pan/usenet-utils/message-check.cc
index 1434013..1587247 100644
--- a/pan/usenet-utils/message-check.cc
+++ b/pan/usenet-utils/message-check.cc
@@ -442,10 +442,11 @@ MessageCheck :: message_check (const GMimeMessage * message_const,
   TextMassager tm;
   gboolean is_html;
   char * body = pan_g_mime_message_get_body (message, &is_html);
-  if (is_html) {
+  if (is_html && !binpost) {
     errors.insert (_("Warning: Most newsgroups frown upon HTML posts."));
     goodness.raise_to_warn ();
   }
+
   if (!binpost)
     check_body (errors, goodness, tm, message, body, attribution);
   g_free (body);



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