Package: altermime
Version: 0.3.7-2
Severity: normal
Tags: patch

altermime doesn't encode the disclaimer text when the mail to be
processed has 

Content-Transfer-Encoding: quoted-printable

and no boundaries as created by KMail it when writing a mail without
attaching anything.

>From looking at the source it seems that alterMIME does not cover this
case. I have written a patch that I thought should fix the problem. 
With this patch the disclaimer text is encoded, but not correctly. All
special characters like different umlauts are encoded to f=FF, while it
should be different encoding values for different special characters.

Maybe I have missed some quoted printable encoding initialization stuff.
I am attaching the patch anyway. Maybe it is easy to fix.

I will inform the upstream author as well.

-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17.7-workstation-sws2-2.2.7
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)
--- mime_alter.c.orig	2007-03-05 11:40:59.102221384 +0100
+++ mime_alter.c	2007-02-28 15:21:47.730173544 +0100
@@ -1248,12 +1248,33 @@
 			// If we have a plain-text email body, then just get to the end of the file
 			//		and append the disclaimer to the end.
 
-			DAM LOGGER_log("%s:%d:AM_add_disclaimer_insert_html:DEBUG: Seeking to the end of the file for plain-text insertion...",FL);
+			DAM LOGGER_log("%s:%d:AM_add_disclaimer_no_boudary:DEBUG: Seeking to the end of the file for plain-text insertion...",FL);
 			/** Read to the end of the file **/
 			AM_read_to_boundary( f, newf, line, AM_1K_BUFFER_SIZE );
 
-			DAM LOGGER_log("%s:%d:AM_add_disclaimer_no_boudary:DEBUG: About to write disclaimer '%s'",FL,dd->disclaimer_text_plain);
-			fprintf(newf,"%s",dd->disclaimer_text_plain);
+                        if (dd->content_encoding != _CTRANS_ENCODING_QP)
+                	{ // No quoted-printable
+				DAM LOGGER_log("%s:%d:AM_add_disclaimer_no_boudary:DEBUG: About to write disclaimer '%s'",FL,dd->disclaimer_text_plain);
+				fprintf(newf,"%s",dd->disclaimer_text_plain);
+			} else { // Quoted-printable encoding
+				/** convert the disclaimer into QP **/
+				char *qp_data;
+				size_t qp_data_size;
+
+				qp_data_size = strlen(dd->disclaimer_text_plain) *3 +1;
+				qp_data = malloc( qp_data_size *sizeof(char));
+				if (qp_data == NULL) {
+					LOGGER_log("%s:%d:AM_add_disclaimer_no_boudary:DEBUG: Error trying to allocate %d bytes of memory for QP encoded disclaimer",FL, qp_data_size); 					return -1;
+				}
+				qp_encode( qp_data, qp_data_size, dd->disclaimer_text_plain, strlen(dd->disclaimer_text_plain));
+				DAM LOGGER_log("%s:%d:AM_add:disclaimer_no_boudary:DEBUG: Inserting QP encoded disclaimer",FL);
+				fprintf( newf, "%s\n", qp_data );
+
+				/** cleanup **/
+				if (qp_data) free(qp_data);
+			} // End of no quoted / quouted-printable alternative
+
+			
 			dd->text_inserted = 1;
 			DAM LOGGER_log("%s:%d:AM_add_disclaimer_no_boudary:DEBUG: Disclaimer now written to file",FL);
 			break;

Reply via email to