/*
* Text client functions for reading and writing of messages
*
- * Copyright (c) 1987-2010 by the citadel.org team
+ * Copyright (c) 1987-2012 by the citadel.org team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "sysdep.h"
}
+/*
+ * This is a mini RFC2047 decoder.
+ * It only handles strings encoded from UTF-8 as Quoted-printable.
+ */
+void mini_2047_decode(char *s) {
+ if (!s) return;
+
+ char *qstart = strstr(s, "=?UTF-8?Q?");
+ if (!qstart) return;
+
+ char *qend = strstr(s, "?=");
+ if (!qend) return;
+
+ if (qend <= qstart) return;
+
+ strcpy(qstart, &qstart[10]);
+ qend -= 10;
+
+ char *p = qstart;
+ while (p < qend) {
+
+ if (p[0] == '=') {
+
+ char ch[3];
+ ch[0] = p[1];
+ ch[1] = p[2];
+ ch[2] = p[3];
+ int c;
+ sscanf(ch, "%02x", &c);
+ p[0] = c;
+ strcpy(&p[1], &p[3]);
+ qend -= 2;
+ }
+
+ if (p[0] == '_') {
+ p[0] = ' ';
+ }
+
+ ++p;
+ }
+
+ strcpy(qend, &qend[2]);
+}
+
/*
* Read a message from the server
*/
scr_printf("part=%s|%s|%s|%s|%s|%ld\n",
ptr->name, ptr->filename, ptr->number,
ptr->disposition, ptr->mimetype,
- ptr->length);
+ ptr->length
+ );
}
}
scr_printf("\n");
safestrncpy(reply_subject, message->subject, sizeof reply_subject);
if (!IsEmptyStr(message->subject)) {
if (dest) {
- fprintf(dest, "Subject: %s\n",
- message->subject);
+ fprintf(dest, "Subject: %s\n", message->subject);
} else {
color(DIM_WHITE);
scr_printf("Subject: ");
color(BRIGHT_CYAN);
+ mini_2047_decode(message->subject);
scr_printf("%s\n", message->subject);
}
}
fp = fopen(filename, "r");
if (fp != NULL) {
fmout(screenwidth, fp, NULL, NULL, 0);
- /* TODO: why ftell if we ignore the result? */
beg = ftell(fp);
if (beg < 0)
scr_printf("failed to get stream position %s\n",