summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/system/system.api.php4
-rw-r--r--modules/upload/upload.module4
-rw-r--r--modules/upload/upload.test10
-rw-r--r--modules/user/user.module2
4 files changed, 13 insertions, 7 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index 58e8212c0..608879d5e 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -1249,8 +1249,8 @@ function hook_file_download($filepath) {
return -1;
}
return array(
- 'Content-Type: ' . $file->filemime,
- 'Content-Length: ' . $file->filesize,
+ 'Content-Type' => $file->filemime,
+ 'Content-Length' => $file->filesize,
);
}
}
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index f5b42c20e..de58b36cc 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -156,8 +156,8 @@ function upload_file_download($filepath) {
if ($file && user_access('view uploaded files') && ($node = node_load($file->nid)) && node_access('view', $node)) {
return array(
- 'Content-Type: ' . $file->filemime,
- 'Content-Length: ' . $file->filesize,
+ 'Content-Type' => $file->filemime,
+ 'Content-Length' => $file->filesize,
);
}
else {
diff --git a/modules/upload/upload.test b/modules/upload/upload.test
index 141b10adf..1fabe2c62 100644
--- a/modules/upload/upload.test
+++ b/modules/upload/upload.test
@@ -51,6 +51,11 @@ class UploadTestCase extends DrupalWebTestCase {
$this->checkUploadedFile(basename($files[0]));
$this->checkUploadedFile(basename($files[1]));
+ // Check that files are also accessible when using private files.
+ variable_set('file_downloads', FILE_DOWNLOADS_PRIVATE);
+ $this->checkUploadedFile(basename($files[0]));
+ $this->checkUploadedFile(basename($files[1]));
+
// Assure that the attachment link appears on teaser view and has correct count.
$node = node_load($node->nid);
$teaser = drupal_render(node_build($node, TRUE));
@@ -195,9 +200,10 @@ class UploadTestCase extends DrupalWebTestCase {
*/
function checkUploadedFile($filename) {
global $base_url;
- $file = realpath(file_directory_path() . '/' . $filename);
- $this->drupalGet($base_url . '/' . file_directory_path() . '/' . $filename, array('external' => TRUE));
+ $file = file_directory_path() . '/' . $filename;
+ $this->drupalGet(file_create_url($file), array('external' => TRUE));
$this->assertResponse(array(200), 'Uploaded ' . $filename . ' is accessible.');
+ $this->assertTrue(strpos($this->drupalGetHeader('Content-Type'), 'text/plain') === 0, t('MIME type is text/plain.'));
$this->assertEqual(file_get_contents($file), $this->drupalGetContent(), 'Uploaded contents of ' . $filename . ' verified.');
// Verify file actually is readable and writeable by PHP.
$this->assertTrue(is_readable($file), t('Uploaded file is readable.'));
diff --git a/modules/user/user.module b/modules/user/user.module
index 7661c37e3..db8977921 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -814,7 +814,7 @@ function user_perm() {
function user_file_download($filepath) {
if (strpos($filepath, variable_get('user_picture_path', 'pictures') . '/picture-') === 0) {
$info = image_get_info(file_create_path($filepath));
- return array('Content-type: ' . $info['mime_type']);
+ return array('Content-Type' => $info['mime_type']);
}
}