diff --git a/modules/file/file.module b/modules/file/file.module index 4fc9985..d6bd361 100644 --- a/modules/file/file.module +++ b/modules/file/file.module @@ -143,9 +143,14 @@ function file_file_download($uri, $field_type = 'file') { $references = file_get_file_references($file, NULL, FIELD_LOAD_CURRENT, $field_type); // If there are no references, stop processing, to avoid returning headers - // for files controlled by other modules. - if (empty($references)) { - return; + // for files controlled by other modules. The only exception to this rule are + // temporary files where the host entity has not yet been saved (for example, + // an image file attached to a node). Such files may always be downloaded by + // their owner and user 1. + + if(empty($references) + && ($file->status == FILE_STATUS_PERMANENT || ( $user->uid !== 1 && $file->uid != $user->uid))) { + return; } // Default to allow access.