Skip to content
Snippets Groups Projects
Commit 68820e23 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #49476 by Moshe: fixed incorrect access check.

parent 999d3daf
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -131,15 +131,18 @@ function upload_download() { ...@@ -131,15 +131,18 @@ function upload_download() {
function upload_file_download($file) { function upload_file_download($file) {
if (user_access('view uploaded files')) { if (user_access('view uploaded files')) {
$file = file_create_path($file); $file = file_create_path($file);
$result = db_query(db_rewrite_sql("SELECT f.nid, f.* FROM {files} f WHERE filepath = '%s'", 'f'), $file); $result = db_query("SELECT f.* FROM {files} f WHERE filepath = '%s'", $file);
if ($file = db_fetch_object($result)) { if ($file = db_fetch_object($result)) {
$name = mime_header_encode($file->filename); $node = node_load($file->nid);
$type = mime_header_encode($file->filemime); if (node_access('view', $node)) {
// Serve images and text inline for the browser to display rather than download. $name = mime_header_encode($file->filename);
$disposition = ereg('^(text/|image/)', $file->filemime) ? 'inline' : 'attachment'; $type = mime_header_encode($file->filemime);
return array('Content-Type: '. $type .'; name='. $name, // Serve images and text inline for the browser to display rather than download.
'Content-Length: '. $file->filesize, $disposition = ereg('^(text/|image/)', $file->filemime) ? 'inline' : 'attachment';
'Content-Disposition: '. $disposition .'; filename='. $name); return array('Content-Type: '. $type .'; name='. $name,
'Content-Length: '. $file->filesize,
'Content-Disposition: '. $disposition .'; filename='. $name);
}
} }
} }
} }
......
...@@ -131,15 +131,18 @@ function upload_download() { ...@@ -131,15 +131,18 @@ function upload_download() {
function upload_file_download($file) { function upload_file_download($file) {
if (user_access('view uploaded files')) { if (user_access('view uploaded files')) {
$file = file_create_path($file); $file = file_create_path($file);
$result = db_query(db_rewrite_sql("SELECT f.nid, f.* FROM {files} f WHERE filepath = '%s'", 'f'), $file); $result = db_query("SELECT f.* FROM {files} f WHERE filepath = '%s'", $file);
if ($file = db_fetch_object($result)) { if ($file = db_fetch_object($result)) {
$name = mime_header_encode($file->filename); $node = node_load($file->nid);
$type = mime_header_encode($file->filemime); if (node_access('view', $node)) {
// Serve images and text inline for the browser to display rather than download. $name = mime_header_encode($file->filename);
$disposition = ereg('^(text/|image/)', $file->filemime) ? 'inline' : 'attachment'; $type = mime_header_encode($file->filemime);
return array('Content-Type: '. $type .'; name='. $name, // Serve images and text inline for the browser to display rather than download.
'Content-Length: '. $file->filesize, $disposition = ereg('^(text/|image/)', $file->filemime) ? 'inline' : 'attachment';
'Content-Disposition: '. $disposition .'; filename='. $name); return array('Content-Type: '. $type .'; name='. $name,
'Content-Length: '. $file->filesize,
'Content-Disposition: '. $disposition .'; filename='. $name);
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment