filename header is not iso-8859-1 decoded
samuelet - February 4, 2008 - 01:40
| Project: | Mailsave |
| Version: | 5.x-3.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Stuart Greenfield |
| Status: | closed |
Description
On my drupal site, iso-8859-1 filename header is not decoded and the url link gets broken.
for example it happens with:
filename="=?iso-8859-1?Q?incontro=5F8=5Ffebbraio=5Facqua.pdf?="Is it a mailsave bug or could it be realted to something else?

#1
Sorry for not getting back to you on this - I've been busy trying to get flash node up and running and mailsave has taken something of a back seat.
It looks like this might be a mailsave bug since it is mailsave that has to extract the filename.
Where is the message coming from? A mobile device? An email client?
If possible, could you send a sample message to mailsave@stuartandnicola.com.
From there I can pick up the message and test it on my system - "real" messages are much easier for me to work with and fault find!
#2
Ok
#3
Sorry, i realize now that mailsave@stuartandnicola.com should be for mailsave importing and testing and not your personal mail.
The mail that i've sent there, was not the original unmanaged mail, but it's its attachment (extracted from a gmail account where it was sent as cc).
I can't sent you a real sample because it was originated from one of my site users.
#4
Is it possible to forward the email from the gmail account? The message you sent is interpreted by mailsave as a text attachment, so I get a literal save of the text file. That is partially useful as I can see the encoded string and think I can fix it, but the easiest way for me to test is from a "native" message.
I don't have an easy way to send myself an ecoded message!!
Thanks!
--edit --
doh - I created a file with a filename using a "non standard" character to force my email client to encode it. When I first try to retrieve the message with mailsave I got an error saying the file could not be copied, and no file was attached.
I thought I had a working patch, but I don't so it needs more work. If you can still send the original message from gmail that would be great as I can test it against your message too.
Thanks
--/edit--
#5
Mail forwarded.
#6
Thanks for the email. Unfortunately the forwarding turned the filenames in to regular filenames!
I created some encoded files to test with myself, and the attached patch seems to fix things.
It will let mailsave decode the filename, and if the filename contains non-ASCII characters these are stripped out and replaced with underscores.
If you are able to test the patch and feedback your findings that would be great!
#7
I have applied the patch. As soon as my site will get a new message from that user i'll report here if it works. Thanks.
#8
I had another patch to release on mailsave, so I have gone ahead and committed this patch as it wasn't causing any adverse effects as far as I can tell. If you are able to test and remember then please post back here.
Equally, if you find any issues, or the patch DOESN'T work for you, please re-open this thread, or raise a new issue.
Thanks!
#9
Just last night i had the confirmation that the patch works (i have the 5.x-3.2 release).
Thanks.
#10
Hi there,
I've tried updating to the module containing the latest patch, but I'm still seeing
=?Windows-1252?B?SU1HMDA0OTUuanBn?=
instead of a thumbnail when I e-mail a post from my Blackberry. Any other thoughts on a fix?
Thanks!
#11
Hmmm, I will need to test this. I'm about go off an a business trip so I'll have to get back to you when I am able to test this further!
#12
Thanks for the speedy reply. I'll play around with the settings on my Blackberry (experiment using other mail accounts to see if this makes a difference, etc). I'll post the results.
Thanks.
#13
I've not forgotten this thread - things are just hectic at the moment, so I'm not getting much Drupal time. Apologies for the delay :-)
#14
Just to confirm the issue, I am seeing the same issue with Blackberry MMS messages. Images attached are being labeled with something similar to, =?Windows-1252?B?SU1HMDAzODkuanBn?=, the same as platofish mentioned above.
Thanks!
#15
Could someone with a Blackberry post an image to mailsave@stuartandnicola.com? I need a message to test!
Mailsave uses the
mb_decode_mimeheaderfunction to decode filenames. If I simulate a filename using either of the strings above then they resolve to IMG00495.jpg and IMG00389.jpg respectively, which are sensible.What mailsave is getting though from a "live" message is the raw, still coded, string.
Thanks.
#16
I just found the issue (for me anyway) is actually with the "Mailsave to CCK Imagefield" add-on module. I moved the code from the patch you provided into the proper location in that module and the blackberry started working great. I think just that module needs an update with your patch.
#17
Doh! Of course - other modules are called before the remaining attachments are saved! The filename decode is happening AFTER other modules have already tried to process the files, so they get the encoded names (I should really try to remember how I write my modules!)
If the patch works that's an ok work-around, but the better fix is for me to update the main mailsave module and decode filenames in there. That's not a problem as there is a bit of processing goes on to tweak mailhandler files so there is an opportunity to fix all the filenames and avoid individual modules having to do it.
I'll try to get round to this shortly.
#18
I have modified the main mailsave module to use a new routine to clean up and decode filenames. This should mean that mailsave generates filenames that are "ready for use" by all other modules, so it won't be necessary to write clean-up code in to each one.
I have given this some testing on my local system using encoded filenames and it seems ok, but if any Blackberry users are able to test that would be great.
I won't commit just yet in the hope someone else tests it and reports back that it's ok!
Thanks in advance.
@spanders - thanks for putting me on the right track here - once I realised what was happening this was pretty easy to fix - and the same bug could have affected other modules that interface to mailsave!
#19
Committed this as version 6.x-1.2.
#20
Automatically closed -- issue fixed for two weeks with no activity.