Closed (fixed)
Project:
Drupal core
Version:
5.0
Component:
upload.module
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
27 Sep 2006 at 17:02 UTC
Updated:
9 Mar 2007 at 08:47 UTC
This is for DRUPAL_5 and DRUPAL_4_7_3.
The .htaccess file that drupal generates in file_directory_path() breaks file previews when clean url's are enabled.
The lines at fault are Options None and RewriteEngine Off.
I know these lines were added as a part of a security fix, but upload_munge_filename was added as well which does a far better cross platform job than the apache specific .htaccess fixes.
| Comment | File | Size | Author |
|---|---|---|---|
| filepreviews.patch.txt | 861 bytes | dopry |
Comments
Comment #1
morbus iffIn going through all my logs on that, dopry and I reached a tentative agreement on this patch, under the assumption that Steve Dondley (who submitted http://drupal.org/node/67244) would have to test and approve it before going forward.
Comment #2
dopry commentedAs an annotation the original reasoning for add the RewriteEngine off with the multiviews fix from Morbus's IRC logs.
May 29 20:41:46 Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /Users/morbus/Conquest/DrupalHEAD/files/_test.php.txt
May 29 20:43:03 xxxxx: add RewriteEngine Off
Since then Option +FollowSymlinks was added resolve http://drupal.org/node/67244
Comment #3
dopry commentedStill holding on Steve Dondeley to test. Locally and on my testing and staging servers I haven't been able to reproduce this error, but they're all identical configs as far as apache/php/mysql is concerned.
Comment #4
Steve Dondley commentedUsing the cvs version of Drupal downloaded today, I don't appear to have the issue with file uploads that I had with the older version, 4.7.x version. File attachments and new logo uploads work fine without the patch installed.
When the 3-line conditional, beginning with <IfModule mod_rewrite.c>, was commented out of the files/.htaccess file, it had no effect on file upload operation.
Comment #5
chx commentedit seems we are better with this patch committed than without.
Comment #6
dopry commentedAlso not to confuse what is at issue here... It is not the file uploads. In order to properly reproduce this error.
1) install clean drupal (4.7.3 or head).
2) enable clean urls.
3) goto node/add/story
4) attach an image file
5) create an <img> tag in the body using the url provided in the file upload box for the image.
6) hit preview, not submit.
You will not see the image preview. If you remove the rewrite engine off from the .htaccess it will work.
This happens because file attachments are not saved to their final location until a node is submitted. However, it is very handy to have that final url when creating a node, so a menu callback is used until the node is submitted.
Since the final url for uploaded attachments will be something like 'files/.../...' and rewrite is disabled in 'files/' you cannot have file previews. The rewrite engine must be on and Options FollowSymlinks is required for the rewrite engine to do internal rewrites. (Morbus, Correct me if I'm wrong).
I believe files in node previews with clean urls enabled and public files is the only core issue here.
I
Comment #7
dries commentedCommitted to DRUPAL-4-7 and CVS HEAD. Thanks.
Comment #8
(not verified) commentedComment #9
dkatzman commentedHi,
How can I disable Drupal from creating the .htaccess in the files folder again and again?
Thanks,
DK