summaryrefslogtreecommitdiffstats
path: root/handler.c
diff options
context:
space:
mode:
authorMichael Elkins <me@sigpipe.org>2002-11-12 08:00:51 +0000
committerMichael Elkins <me@sigpipe.org>2002-11-12 08:00:51 +0000
commit37e934cec19158fbf25e15aa43993737d2af14b6 (patch)
treec060d1f43d512d2737c0c5e6e83f653f1a61b8a5 /handler.c
parentcf29e482598ee41a37bfc7db6f72540447552504 (diff)
Actually commit patch-1.5.1.me.long_qp.2.
Diffstat (limited to 'handler.c')
-rw-r--r--handler.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/handler.c b/handler.c
index 3cdd24fc..fd9f2435 100644
--- a/handler.c
+++ b/handler.c
@@ -182,16 +182,6 @@ static void qp_decode_line (char *dest, char *src, size_t *l,
int kind;
int soft = 0;
- /* chop trailing whitespace */
-
- if (*src)
- {
- s = src + strlen(src) - 1;
- while (s >= src && ISSPACE(*s))
- s--;
- *(++s) = '\0';
- }
-
/* decode the line */
for (d = dest, s = src; *s;)
@@ -240,10 +230,10 @@ void mutt_decode_quoted (STATE *s, long len, int istext, iconv_t cd)
char line[STRING];
char decline[2*STRING];
size_t l = 0;
- size_t linelen; /* number of input bytes in `line' */
+ size_t linelen; /* number of input bytes in `line' */
size_t l3;
- int last; /* store the last character in the input line */
+ int last; /* store the last character in the input line */
if (istext)
state_set_prefix(s);
@@ -253,11 +243,11 @@ void mutt_decode_quoted (STATE *s, long len, int istext, iconv_t cd)
last = 0;
/*
- * its ok to use a fixed since buffer for input, even if the line turns
- * out to be longer than this. we will just dynamically grow the output
- * buffer and process the line in chunks. this really shouldn't happen
- * according the MIME spec, since Q-P encoded lines are at most 76
- * characters, but we should be liberal about what we expect.
+ * It's ok to use a fixed size buffer for input, even if the line turns
+ * out to be longer than this. Just process the line in chunks. This
+ * really shouldn't happen according the MIME spec, since Q-P encoded
+ * lines are at most 76 characters, but we should be liberal about what
+ * we accept.
*/
if (fgets (line, MIN ((ssize_t)sizeof (line), len + 1), s->fpin) == NULL)
break;
@@ -271,6 +261,14 @@ void mutt_decode_quoted (STATE *s, long len, int istext, iconv_t cd)
*/
last = linelen ? line[linelen - 1] : 0;
+ /* chop trailing whitespace if we got the full line */
+ if (last == '\n')
+ {
+ while (linelen > 0 && ISSPACE (line[linelen-1]))
+ linelen--;
+ line[linelen]=0;
+ }
+
/* decode and do character set conversion */
qp_decode_line (decline + l, line, &l3, last);
l += l3;