Commit 9ecb9a89 authored by Dries's avatar Dries

- Patch #1221214 by chx: file_download() returns 404 instead of 403.

parent 0114ad6d
...@@ -1902,10 +1902,11 @@ function file_transfer($uri, $headers) { ...@@ -1902,10 +1902,11 @@ function file_transfer($uri, $headers) {
* Menu handler for private file transfers. * Menu handler for private file transfers.
* *
* Call modules that implement hook_file_download() to find out if a file is * Call modules that implement hook_file_download() to find out if a file is
* accessible and what headers it should be transferred with. If a module * accessible and what headers it should be transferred with. If one or more
* returns -1 drupal_access_denied() will be returned. If one or more modules * modules returned headers the download will start with the returned headers.
* returned headers the download will start with the returned headers. If no * If a module returns -1 drupal_access_denied() will be returned. If the file
* modules respond drupal_not_found() will be returned. * exists but no modules responded drupal_access_denied() will be returned.
* If the file does not exist drupal_not_found() will be returned.
* *
* @see hook_file_download() * @see hook_file_download()
*/ */
...@@ -1934,6 +1935,7 @@ function file_download() { ...@@ -1934,6 +1935,7 @@ function file_download() {
if (count($headers)) { if (count($headers)) {
file_transfer($uri, $headers); file_transfer($uri, $headers);
} }
return drupal_access_denied();
} }
return drupal_not_found(); return drupal_not_found();
} }
......
...@@ -1091,6 +1091,6 @@ class FilePrivateTestCase extends FileFieldTestCase { ...@@ -1091,6 +1091,6 @@ class FilePrivateTestCase extends FileFieldTestCase {
$this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.'));
$this->drupalLogOut(); $this->drupalLogOut();
$this->drupalGet(file_create_url($node_file->uri)); $this->drupalGet(file_create_url($node_file->uri));
$this->assertNoResponse(200, t('Confirmed that access is denied for the file without the needed permission.')); $this->assertResponse(403, t('Confirmed that access is denied for the file without the needed permission.'));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment