1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-24 09:55:33 +02:00

Merge branch 'wip_MDL-47966_m28_defaultheaders' of https://github.com/skodak/moodle

This commit is contained in:
Damyon Wiese 2014-11-03 12:20:58 +08:00
commit 520a32c3d4

@ -772,6 +772,24 @@ if (empty($CFG->sessiontimeout)) {
}
\core\session\manager::start();
// Set default content type and encoding, developers are still required to use
// echo $OUTPUT->header() everywhere, anything that gets set later should override these headers.
// This is intended to mitigate some security problems.
if (AJAX_SCRIPT) {
if (!core_useragent::supports_json_contenttype()) {
// Some bloody old IE.
@header('Content-type: text/plain; charset=utf-8');
@header('X-Content-Type-Options: nosniff');
} else if (!empty($_FILES)) {
// Some ajax code may have problems with json and file uploads.
@header('Content-type: text/plain; charset=utf-8');
} else {
@header('Content-type: application/json; charset=utf-8');
}
} else if (!CLI_SCRIPT) {
@header('Content-type: text/html; charset=utf-8');
}
// Initialise some variables that are supposed to be set in config.php only.
if (!isset($CFG->filelifetime)) {
$CFG->filelifetime = 60*60*6;