Revision 427 src/procmime.c
| procmime.c (revision 427) | ||
|---|---|---|
| 197 | 197 |
#endif |
| 198 | 198 |
|
| 199 | 199 |
if (mimeinfo) {
|
| 200 |
mimeinfo->size = get_left_file_size(fp); |
|
| 200 |
mimeinfo->size = msginfo->size; |
|
| 201 |
mimeinfo->content_size = get_left_file_size(fp); |
|
| 202 |
if (mimeinfo->encoding_type == ENC_BASE64) |
|
| 203 |
mimeinfo->content_size = mimeinfo->content_size / 4 * 3; |
|
| 201 | 204 |
if (mimeinfo->mime_type == MIME_MULTIPART || |
| 202 | 205 |
mimeinfo->mime_type == MIME_MESSAGE_RFC822) |
| 203 | 206 |
procmime_scan_multipart_message(mimeinfo, fp); |
| ... | ... | |
| 248 | 251 |
for (;;) {
|
| 249 | 252 |
MimeInfo *partinfo; |
| 250 | 253 |
gboolean eom = FALSE; |
| 254 |
glong content_pos; |
|
| 255 |
gboolean is_base64; |
|
| 251 | 256 |
gint len; |
| 257 |
guint b64_content_len = 0; |
|
| 258 |
gint b64_pad_len = 0; |
|
| 252 | 259 |
|
| 253 | 260 |
prev_fpos = fpos; |
| 254 | 261 |
debug_print("prev_fpos: %ld\n", fpos);
|
| 255 | 262 |
|
| 263 |
/* scan part header */ |
|
| 256 | 264 |
if (mimeinfo->mime_type == MIME_MESSAGE_RFC822) {
|
| 257 | 265 |
MimeInfo *sub; |
| 258 | 266 |
|
| 259 | 267 |
mimeinfo->sub = sub = procmime_scan_mime_header(fp); |
| 260 | 268 |
if (!sub) break; |
| 261 | 269 |
|
| 270 |
debug_print("message/rfc822 part found\n");
|
|
| 262 | 271 |
sub->level = mimeinfo->level + 1; |
| 263 | 272 |
sub->parent = mimeinfo->parent; |
| 264 | 273 |
sub->main = mimeinfo; |
| ... | ... | |
| 272 | 281 |
partinfo->content_type); |
| 273 | 282 |
} |
| 274 | 283 |
|
| 284 |
/* begin content */ |
|
| 285 |
content_pos = ftell(fp); |
|
| 286 |
debug_print("content_pos: %ld\n", content_pos);
|
|
| 287 |
|
|
| 275 | 288 |
if (partinfo->mime_type == MIME_MULTIPART || |
| 276 | 289 |
partinfo->mime_type == MIME_MESSAGE_RFC822) {
|
| 277 | 290 |
if (partinfo->level < 8) |
| ... | ... | |
| 280 | 293 |
|
| 281 | 294 |
/* look for next boundary */ |
| 282 | 295 |
buf[0] = '\0'; |
| 296 |
is_base64 = partinfo->encoding_type == ENC_BASE64; |
|
| 283 | 297 |
while ((p = fgets(buf, sizeof(buf), fp)) != NULL) {
|
| 284 | 298 |
if (IS_BOUNDARY(buf, boundary, boundary_len)) {
|
| 285 | 299 |
if (buf[2 + boundary_len] == '-' && |
| 286 | 300 |
buf[2 + boundary_len + 1] == '-') |
| 287 | 301 |
eom = TRUE; |
| 288 | 302 |
break; |
| 303 |
} else if (is_base64) {
|
|
| 304 |
const gchar *s; |
|
| 305 |
for (s = buf; *s && *s != '\r' && *s != '\n'; |
|
| 306 |
++s) |
|
| 307 |
if (*s == '=') |
|
| 308 |
++b64_pad_len; |
|
| 309 |
b64_content_len += s - buf; |
|
| 289 | 310 |
} |
| 290 | 311 |
} |
| 291 | 312 |
if (p == NULL) {
|
| ... | ... | |
| 300 | 321 |
|
| 301 | 322 |
len = strlen(buf); |
| 302 | 323 |
partinfo->size = fpos - prev_fpos - len; |
| 324 |
if (is_base64) |
|
| 325 |
partinfo->content_size = |
|
| 326 |
b64_content_len / 4 * 3 - b64_pad_len; |
|
| 327 |
else |
|
| 328 |
partinfo->content_size = fpos - content_pos - len; |
|
| 303 | 329 |
debug_print("partinfo->size: %d\n", partinfo->size);
|
| 330 |
debug_print("partinfo->content_size: %d\n",
|
|
| 331 |
partinfo->content_size); |
|
| 304 | 332 |
if (partinfo->sub && !partinfo->sub->sub && |
| 305 | 333 |
!partinfo->sub->children) {
|
| 306 | 334 |
partinfo->sub->size = |
Also available in: Unified diff