Almost 2 months without any reaction to http://drupal.org/node/395428
Trying again, starting a new issue...
When downloading files:
1- jpg and pdf files are readily opened and keep their original name
2- pub (MS Publisher) files completely lose their extension.
The file name follows the same rules as bellow depending on the browser.
3- other files generally keep their extension, but are renamed.
The name seems to be arbitrarily chosen by the web browser.
For example for the same file originally named "s88-01.doc"
- Firefox rename it "H8jB6jTR.doc.part.doc"
- Chrome rename it "download (1).doc" (all files are named "download", with the number incrementing)
- IE rename it "controlchaingroup_fr.doc", from the name off the web site "controlchaingroup.fr"
In all browsers, the correct name appear when overflying the file link.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | upload.module.d5.content-disposition.patch | 444 bytes | ngaur |
| #18 | upload.module.d6.content-disposition.patch | 438 bytes | ngaur |
| #18 | upload.module.d7.content-disposition.patch | 432 bytes | ngaur |
| #21 | upload.module.d6.content-disposition.patch | 443 bytes | ngaur |
| #14 | upload.module.d5.content-disposition.patch | 375 bytes | ngaur |
Comments
Comment #1
jvieille commentedREALLY NEED HELP!!!
This module would be really great, if it was working
Comment #2
jvieille commentedI found it!
This is a several versions old problem.... Looks like almost nobody need file access control!
It has been silently solved here:
http://drupal.org/node/180778#comment-318639
The patch is here:
http://drupal.org/files/issues/upload.module.d6.content-disposition_0.patch
I hacked my clean (now dirty) D6.10: just added this line
'Content-Disposition: filename="'. mime_header_encode($file->filename) .'"',
after the line 154 in upload.module
May we havve htis committed in Core please!
Comment #3
Stol commentedThis is indeed an old issue. I use the filefield of CCK instead of of the upload module. At least in Drupal 5 the filefield module doesn't have this issue.
Comment #4
jvieille commentedThe CCK filefield does everything but proper access control.
I need the simple and lean Core upload module working as I use Private Upload to control file access,, and this module is not compatible with Fielfield.
If it this module is not planned to be fixed, it shall be removed as this is a critical bug!
But the fix is so simple that it would be extremely interesting to know the valid reason why it could not be committed.
We get core updates on a regular basis that only seem to address security issues that would only be of importance exceptionnally compared to such really annoying bug.
Comment #5
ngaur commentedI'm setting this to status: needs review, as it looks likely that the patch you've located is to the point.
I'm also renaming this issue to more clearly describe the problem.
Anyone reviewing this should look at #180778: Implement Content-Disposition comments #15 and #16 for the appropriate patches, which are quick to understand and apply.
Comment #6
jvieille commentedWhat kind of review is still needed?
The fix was issued in 2007...
May be not many people protect their files, so not much dedication to solve the issue.
Whatever happens with the fix, it cannot be worse than the current situation where using private files simply does not work.
Comment #7
ngaur commentedTell me if I'm wrong, but I figure that needs review means it's not a case of the bug needing to be found so much as the solution needs to be checked for correctness. I'm new to the drupal project's workflow though, and I'm quite ready to be corrected.
OK, so here's some review.
I've just taken a look at RFC 2183. The header format implemented in the patch is not RFC compliant.
1/ It needs the disposition-type to be specified. Looks like 'attachment' is the apropriate value So, the added line would now look something like:
A significant effect of this is that it forces a browser to download the file. eg a .pdf file will not be displayed in a window care of a user's Adobe acrobat plugin. That's probably a good thing.
2/ RFC 2183 stipulates that the filename MUST be encoded as specified in RFC 2184. However, It looks like Drupal's mime_header_encode function documentation refers to RFC 2047. I'm not familiar with all of what has changed, but given the dates of the documents, I'd say that unicode would be the big one. RFC 2047 dates back to 1996 when unicode had little to no support in mail and web software. Unlike RFC 2047, The code of the drupal function refers to UTF-8, so there's a documentation bug at best. My reading of the encoding function says that it doesn't necessarily escape 'tspecials' (see RFC 2045), including characters like ',', ':', ' ', '=' and ';' which MIME uses to delimit fields in the header, and which would create problems if the header line were to wrap (valid MIME behaviour, but presumably uncommon in web browsers). One would hope that web browsers don't trust server headers enough for this to be exploitable.
At this moment, mime_header_encode does not provide a suitable encoding function for the proposed purpose. That should be fixed.
Comment #8
jvieille commentedThat's a bit too technical for me...
I suggest that this new - certainly very valuable comment - should be taken into account as a separate issue.
the currrent patch solves the problem almost 100%, it does not seem to make Drupal core "worse" than it is currently.
This new input willl simpy mprove things.
The problem is that we are going to dig into another probelm that will postpone the fix for years again - the community is still waiting for 2 years for this imple line of code
Comment #9
ngaur commentedI'd agree with you in regards to my second point, but not in regards to my first point.
Corrected Patches attached. These are untested, but should be fine. Let me know how you go with them.
The fix to the mime header encoding should be treated as a separate issue. I've been meaning to file a bug report, but haven't had much time.
Comment #10
jvieille commentedThat OK for me.
Works at best.
Comment #11
ngaur commentedCan someone commit this please?
Comment #12
gábor hojtsyDrupal 7 goes first.
Comment #14
ngaur commentedNew patch versions.
Comment #15
albertoperego commentedlove you!! It works!!
Comment #16
ngaur commentedalbertoperego, could you clarify which drupal version you've tested this with?
Comment #18
ngaur commentedPatch files were produced with file names relative to the wrong working directory, so the automated testing system complained.
These new versions of the patch files should hopefully keep it happy.
[Note - it seems I can edit the comment, but not mark the D6 patch as being incorrect. See #21 below]
Comment #19
antosanto commentedThe correct line to add is:
'Content-Disposition: attachment; filename="'. mime_header_encode($file->filename) .'"'
instead of
'Content-Length: attachment; filename="'. mime_header_encode($file->filename) .'"'
This works for me on Drupal-6.13
Greetings.
Comment #20
cmorrish commentedOur set up uses the private file download option.
After upgrading to D6 from D5, prior to putting in this hack, excel files on our system were being re-named with a 'doc' suffix and would not display or save . With the hack, while an excel file was displayed in the download dialog in IE6 as excel, and saved ok, in Firefox on the mac it was still displaying as a word document for download, and the headers indicated a Content type of 'application/msword'. With the latest upgrade to 6.14, the hack didn't seem to work it's usual magic.
I disabled the contributed module imce, and the problem went away.
Might the difficulty generally lie in contributed modules that use hook_file_download possibly over-riding the Content type set by the Upload module?
After copious drupal_set_message tests (there is probably an easier way, but I ain't no coder!) I found in my case it was the use of finfo_file at line 92 in imce.module that set the header Content type to "application/msword", which then overrode the original upload module type header of "application/vnd.ms-excel".
Below was my temporary solution for imce which may help as an illustration if there are other modules involved (will also post to the imce issues)
Swap the order of the 'finfo_file' test that is causing errors, with the db test that works ok.
Original (at line 91 in imce.module) -
Change to -
Used a swap rather than a comment out, as the least disruptive option. And it's good to have the option of viewing in the browser again.
Hope this is of some help, I've set it back to active (with the greatest trepidation) because I'm not sure this would resolve the original difficulty that @jvieille was having ... but I think the problem may not be in core.
Cliona
Comment #21
ngaur commentedCorrected D6 version of the patch attached. I believe the ones for D5 and D7 are correct.
Can people who use these successfully (or not) please say so on this page. It's a bit frustrating to have fixed the problem but have noone stepping in to commit it. Perhaps some feedback will help that process.
Comment #22
jvieille commentedFor me, it works since I discovered in April a patch form Feb 2008.
The latest patch is fine too.
Should have been committed a long time ago.. Still hacking Drupal core each time a new version is released...
Hope this helps
Comment #23
wims commentedYes, worked for mee to.
Drupal 6.14
Thanks,
Wims
Comment #24
gruzik commentedI have similar problem, except that I don't use upload module (uploading files via FTP).
- Drupal 6.15
- private file system
- FCKEditor + IMCE as file browser
File names are totally messed up. Switching between private and public file access don't help.
What to do if I don't use the upload module?
Andrzej
Comment #25
dpearcefl commentedHas this been fixed in the latest D6?
Comment #26
dpearcefl commented