Skip to content

Commit

Permalink
MDL-32889 lib: escape filename in Content-Disposition header
Browse files Browse the repository at this point in the history
  • Loading branch information
mackensen committed May 9, 2012
1 parent e16e230 commit 66969d5
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion admin/user/user_bulk_download.php
Expand Up @@ -152,7 +152,7 @@ function user_download_csv($fields) {
$filename = clean_filename(get_string('users').'.csv');

header("Content-Type: application/download\n");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
header("Pragma: public");
Expand Down
2 changes: 1 addition & 1 deletion course/lib.php
Expand Up @@ -566,7 +566,7 @@ function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
$filename = 'logs_'.userdate(time(),get_string('backupnameformat', 'langconfig'),99,false);
$filename .= '.txt';
header("Content-Type: application/download\n");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
header("Pragma: public");
Expand Down
4 changes: 2 additions & 2 deletions lib/excel/test.php
Expand Up @@ -6,7 +6,7 @@

function HeaderingExcel($filename) {
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$filename" );
header("Content-Disposition: attachment; filename=\"$filename\"" );
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
Expand Down Expand Up @@ -87,4 +87,4 @@ function HeaderingExcel($filename) {
//$worksheet2->insert_bitmap(0, 0, "some.bmp",10,10);

$workbook->close();
?>
?>
2 changes: 1 addition & 1 deletion lib/filelib.php
Expand Up @@ -1801,7 +1801,7 @@ function send_temp_file($path, $filename, $pathisstring=false) {
$filename = urlencode($filename);
}

header('Content-Disposition: attachment; filename='.$filename);
header('Content-Disposition: attachment; filename="'.$filename.'"');
if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
header('Cache-Control: max-age=10');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
Expand Down
2 changes: 1 addition & 1 deletion mod/data/lib.php
Expand Up @@ -2724,7 +2724,7 @@ function data_export_csv($export, $delimiter_name, $dataname, $count, $return=fa
$filename .= '.csv';
if (empty($return)) {
header("Content-Type: application/download\n");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Disposition: attachment; filename=\"$filename\"");
header('Expires: 0');
header('Cache-Control: must-revalidate,post-check=0,pre-check=0');
header('Pragma: public');
Expand Down
2 changes: 1 addition & 1 deletion mod/feedback/export.php
Expand Up @@ -168,6 +168,6 @@ function feedback_get_xml_data($feedbackid) {

function feedback_send_xml_data($data, $filename) {
@header('Content-Type: application/xml; charset=UTF-8');
@header('Content-Disposition: attachment; filename='.$filename);
@header('Content-Disposition: attachment; filename="'.$filename.'"');
print($data);
}

0 comments on commit 66969d5

Please sign in to comment.