diff options
-rwxr-xr-x | ext/mailparse/rfc2045.h | 6 | ||||
-rwxr-xr-x | ext/mailparse/rfc2045cdecode.c | 13 |
2 files changed, 16 insertions, 3 deletions
diff --git a/ext/mailparse/rfc2045.h b/ext/mailparse/rfc2045.h index 30d93e6bb8..388620d40e 100755 --- a/ext/mailparse/rfc2045.h +++ b/ext/mailparse/rfc2045.h @@ -195,6 +195,12 @@ char *rfc2045_content_base(struct rfc2045 *p); char *rfc2045_append_url(const char *, const char *); /* Do this with two arbitrary URLs */ + + +void rfc2045_add_workbuf(struct rfc2045 *h, const char *p, size_t len); +void rfc2045_add_workbufch(struct rfc2045 *h, int c); + + #ifdef __cplusplus } #endif diff --git a/ext/mailparse/rfc2045cdecode.c b/ext/mailparse/rfc2045cdecode.c index 971c59d77b..858f48dfde 100755 --- a/ext/mailparse/rfc2045cdecode.c +++ b/ext/mailparse/rfc2045cdecode.c @@ -10,10 +10,15 @@ static int op_func(int c, void *dat) { - unsigned char C = (unsigned char)c; struct rfc2045 * p = (struct rfc2045*)dat; - - (*p->udecode_func)(&C, 1, p->misc_decode_ptr); + + rfc2045_add_workbufch(p, c); + + /* drain buffer */ + if (p->workbuflen >= 4096) { + (*p->udecode_func)(p->workbuf, p->workbuflen, p->misc_decode_ptr); + p->workbuflen = 0; + } return c; } @@ -57,6 +62,8 @@ int rfc2045_cdecode_end(struct rfc2045 *p) mbfl_convert_filter_flush(p->decode_filter); mbfl_convert_filter_delete(p->decode_filter); p->decode_filter = NULL; + if (p->workbuflen > 0) + (*p->udecode_func)(p->workbuf, p->workbuflen, p->misc_decode_ptr); } return 0; } |