#1488403 closed Bugs (worksforme)
undecoded attachment link
| Reported by: | pspinc | Owned by: | |
|---|---|---|---|
| Priority: | 2 | Milestone: | 0.8-rc |
| Component: | MIME parsing | Version: | 0.5.2 |
| Severity: | major | Keywords: | attachment, filename, link, encode |
| Cc: |
Description
When I attach a file using Chinese or Japanese character for the filename and body, the link I click to download or preview has is filename encoded, so the system does not understand what file type it is, I believe using urldecode can solve the problem but dont know how, I will add a snap shot for evidence. And I am sorry if this has been fixed already, please let me know, thank you.
Attachments (1)
Change History (6)
Changed 15 months ago by pspinc
comment:1 Changed 15 months ago by alec
- Milestone changed from later to 0.8-rc
- Resolution set to worksforme
- Status changed from new to closed
comment:2 Changed 15 months ago by pspinc
So I enabled imap_debug and I see information regarding to that attachment is as following.
Content-Type: application/octet-stream; name="=?UTF-8?B?44GL44GN44GP44GR44GTLmRvY3g=?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename*0*=UTF-8%E3%81%8B%E3%81%8D%E3%81%8F%E3%81%91%E3%81%93%2E%64%6F; filename*1*=%63%78
the encoded name under "content-type" can be decoded properly using imap->decode_header() function, and PHP urldecode function can take care of all the % char under the "content-disposition". I figured this much out to make the file name displayed properly. But when I click the attachment, the command "load-attachment" will get action and uid of message plus mime_id (usually start from 2), but the result is still the same as my picture added yesterday, everything is still looks like "Content-Disposition". Since my company adapted the 0.5.2 version like long times ago, we've been customize the code and make it different, so simply using the newest version is impossible. Right now the attachment is not properly decoded only when I click the link to download.
Any idea where to fix? I think it's either on app.js or get.inc.
Much appreciation
Nan
comment:3 Changed 15 months ago by pspinc
And here is the BODYSTRUCTURE:
C: A0004 UID FETCH 149990 (UID RFC822.SIZE FLAGS INTERNALDATE BODYSTRUCTURE BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT CONTENT-TYPE LIST-POST DISPOSITION-NOTIFICATION-TO REPLY-TO IN-REPLY-TO CC BCC Msg-ID CONTENT-TRANSFER-ENCODING REFERENCES X-PRIORITY X-DRAFT-INFO MAIL-FOLLOWUP-TO MAIL-REPLY-TO RETURN-PATH)])
Mar 21 09:29:57 localhost WebdeMail? 3: S: * 83 FETCH (UID 149990 RFC822.SIZE 20112 FLAGS (\Seen) INTERNALDATE "19-Mar-2012 09:51:48 -0700" BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "UTF-8") NIL NIL "quoted-printable" 49 2)("APPLICATION" "OCTET-STREAM" ("NAME" "UTF-8%E3%81%8B%E3%81%8D%E3%81%8F%E3%81%91%E3%81%93%2E%64%6F") NIL NIL "base64" 17496 NIL ("attachment" ("FILENAME" "UTF-8%E3%81%8B%E3%81%8D%E3%81%8F%E3%81%91%E3%81%93%2E%64%6F"))) "MIXED" ("BOUNDARY" "------------070409000705060303040000") NIL NIL) BODY[HEADER.FIELDS (DATE FROM TO SUBJECT CONTENT-TYPE LIST-POST DISPOSITION-NOTIFICATION-TO REPLY-TO IN-REPLY-TO CC BCC Msg-ID CONTENT-TRANSFER-ENCODING REFERENCES X-PRIORITY X-DRAFT-INFO MAIL-FOLLOWUP-TO MAIL-REPLY-TO RETURN-PATH)] {319}
Hope it helps
comment:4 Changed 15 months ago by pspinc
Also when I clicked the link, the log from imap_debug displayed the whole content which is encoded as the filename:name="=?UTF-8?B?44GL44GN44GP44GR44GTLmRvY3g=?=". I believe imap->decode_header can do the work but the problem is: where is the function to get all the content?
comment:5 Changed 15 months ago by pspinc
{{{A little correction for the last comment, the content was not encoded as the filename and certainly cannot be decoded by the imap decode header function. Base64_decode can make the most decryption but with bad chars
i.e Base64_decode(UEsDBBQABgAIAAAAIQAJJIeCgQEAAI4FAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
will display
PK! $����[Content_Types].xml �(�
}}}

Works for me. Try with newer version. If it will not help, enable imap_debug and provide BODYSTRUCTURE response. It might be your IMAP server issue. Provide message source (headers).