HTML messages are now encoded as "Quoted-Printable" before being
authorArt Cancro <ajc@citadel.org>
Mon, 30 Jan 2006 05:15:09 +0000 (05:15 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 30 Jan 2006 05:15:09 +0000 (05:15 +0000)
  transmitted to the server.  New utility function text_to_server_qp()
  handles this.

webcit/ChangeLog
webcit/messages.c
webcit/serv_func.c
webcit/webcit.h

index 3014c39dda5b256bb6e01d649e4227a96b4d72e0..01a426bc783e0431d0b3fb03b6afb6e49d863b77 100644 (file)
@@ -1,5 +1,10 @@
 $Id$
 
+Mon Jan 30 00:14:06 EST 2006 ajc
+* HTML messages are now encoded as "Quoted-Printable" before being
+  transmitted to the server.  New utility function text_to_server_qp()
+  handles this.
+
 Sun Jan 29 23:20:48 EST 2006 ajc
 * Removed the "convert_to_html" option from text_to_server() because we no
   longer have any callers which require it.
index 37aeb321f6add845a808b88b8b04724824d5d6a4..8dadcf0cec666ad72137264c7408e83746ba21da 100644 (file)
@@ -2443,12 +2443,12 @@ void post_mime_to_server(void) {
        }
 
        serv_puts("Content-type: text/html; charset=utf-8");
+       serv_puts("Content-Transfer-Encoding: quoted-printable");
        serv_puts("");
-       serv_puts("<html><body>\n");            /** Future templates go here */
-       text_to_server(bstr("msgtext"));
-       serv_puts("</body></html>\n");
+       serv_puts("<html><body>\r\n");
+       text_to_server_qp(bstr("msgtext"));     /** Transmit message in quoted-printable encoding */
+       serv_puts("</body></html>\r\n");
        
-
        if (is_multipart) {
 
                /** Add in the attachments */
index 2325d8dbfcc5a9db27c8809d503e4bb6c30f24d8..9f946ddbc19e27266f0ed9471f976986cc78a6c9 100644 (file)
@@ -225,6 +225,81 @@ void text_to_server(char *ptr)
 }
 
 
+/**
+ * \brief Transmit message text (in memory) to the server,
+ *        converting to Quoted-Printable encoding as we go.
+ *
+ * \param ptr Pointer to the message being transmitted
+ */
+void text_to_server_qp(char *ptr)
+{
+       char buf[256];
+       int ch, pos;
+       int output_len = 0;
+
+       pos = 0;
+       buf[0] = 0;
+       output_len = 0;
+
+       while (ptr[pos] != 0) {
+               ch = ptr[pos++];
+
+               if (ch == 13) {
+                       /* ignore carriage returns */
+               }
+               else if (ch == 10) {
+                       /* hard line break */
+                       if (output_len > 0) {
+                               if (isspace(buf[output_len-1])) {
+                                       sprintf(&buf[output_len-1], "=%02X", buf[output_len-1]);
+                                       output_len += 2;
+                               }
+                       }
+                       buf[output_len++] = 0;
+                       serv_puts(buf);
+                       output_len = 0;
+               }
+               else if (ch == 9) {
+                       buf[output_len++] = ch;
+               }
+               else if ( (ch >= 32) && (ch <= 60) ) {
+                       buf[output_len++] = ch;
+               }
+               else if ( (ch >= 62) && (ch <= 126) ) {
+                       buf[output_len++] = ch;
+               }
+               else {
+                       sprintf(&buf[output_len], "=%02X", ch);
+                       output_len += 3;
+               }
+               
+               if (output_len > 72) {
+                       /* soft line break */
+                       if (isspace(buf[output_len-1])) {
+                               sprintf(&buf[output_len-1], "=%02X", buf[output_len-1]);
+                               output_len += 2;
+                       }
+                       buf[output_len++] = '=';
+                       buf[output_len++] = 0;
+                       serv_puts(buf);
+                       output_len = 0;
+               }
+       }
+
+       /* end of data - transmit anything that's left */
+       if (output_len > 0) {
+               if (isspace(buf[output_len-1])) {
+                       sprintf(&buf[output_len-1], "=%02X", buf[output_len-1]);
+                       output_len += 2;
+               }
+               buf[output_len++] = 0;
+               serv_puts(buf);
+               output_len = 0;
+       }
+}
+
+
+
 
 /**
  * \brief translate server message output to text
index 953b798fbca373e98e6782e9e403c8f983141f5a..ffa329a7d6fda9247faa987a33e5d0dcae2b2db7 100644 (file)
@@ -482,6 +482,7 @@ void embed_message(char *msgnum_as_string);
 void print_message(char *msgnum_as_string);
 void display_headers(char *msgnum_as_string);
 void text_to_server(char *ptr);
+void text_to_server_qp(char *ptr);
 void display_enter(void);
 void post_message(void);
 void confirm_delete_msg(void);