mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-09-07 08:11:07 +02:00
WR #490867 auth_outage Review changes - sanitise header metadata and file request parameters, restrict served mime types, guard warning bar css output, move svgicons config change out of constructor, add missing form field types
This commit is contained in:
@@ -67,6 +67,7 @@ class edit extends moodleform {
|
||||
$mform->addHelpButton('title', 'title', 'auth_outage');
|
||||
|
||||
$mform->addElement('editor', 'description', get_string('description', 'auth_outage'));
|
||||
$mform->setType('description[text]', PARAM_RAW);
|
||||
$mform->addHelpButton('description', 'description', 'auth_outage');
|
||||
|
||||
$mform->addElement('static', 'usagehints', '', get_string('textplaceholdershint', 'auth_outage'));
|
||||
@@ -79,6 +80,7 @@ class edit extends moodleform {
|
||||
get_string('useaccesskey:desc', 'auth_outage'),
|
||||
0
|
||||
);
|
||||
$mform->setType('useaccesskey', PARAM_BOOL);
|
||||
|
||||
$mform->addElement('text', 'accesskey', get_string('accesskey', 'auth_outage'));
|
||||
$mform->setType('accesskey', PARAM_TEXT);
|
||||
|
||||
@@ -47,11 +47,6 @@ class infopage {
|
||||
* @param array|null $params Parameters to use or null to get from Moodle API (request).
|
||||
*/
|
||||
public function __construct(?array $params = null) {
|
||||
global $CFG;
|
||||
// Enable SVG support here to make sure all SVG files
|
||||
// used in the current theme are served properly.
|
||||
$CFG->svgicons = true;
|
||||
|
||||
if (is_null($params)) {
|
||||
$params = [
|
||||
'id' => optional_param('id', null, PARAM_INT),
|
||||
@@ -92,6 +87,10 @@ class infopage {
|
||||
*/
|
||||
public function output() {
|
||||
global $PAGE, $CFG, $OUTPUT;
|
||||
// Enable SVG support here to make sure all SVG files
|
||||
// used in the current theme are served properly.
|
||||
$previoussvg = $CFG->svgicons ?? null;
|
||||
$CFG->svgicons = true;
|
||||
|
||||
if (is_null($this->outage)) {
|
||||
redirect(new moodle_url('/'));
|
||||
@@ -111,7 +110,8 @@ class infopage {
|
||||
|
||||
// Inject metadata into the header before output.
|
||||
if (!empty($this->outage->metadata)) {
|
||||
header('X-Outage-Metadata: ' . $this->outage->metadata);
|
||||
$safemeta = str_replace(["\r", "\n"], '', $this->outage->metadata);
|
||||
header('X-Outage-Metadata: ' . $safemeta);
|
||||
header('X-Outage-StartTime: ' . $this->outage->starttime);
|
||||
header('X-Outage-EndTime: ' . $this->outage->stoptime);
|
||||
}
|
||||
@@ -127,6 +127,7 @@ class infopage {
|
||||
if (!($CFG->branch == '27' && CLI_SCRIPT)) {
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
$CFG->svgicons = $previoussvg;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,8 @@ class maintenance_static_page {
|
||||
} else {
|
||||
// Inject metadata into the header before output.
|
||||
if (!empty($outage->metadata)) {
|
||||
header('X-Outage-Metadata: ' . $outage->metadata);
|
||||
$safemeta = str_replace(["\r", "\n"], '', $outage->metadata);
|
||||
header('X-Outage-Metadata: ' . $safemeta);
|
||||
header('X-Outage-StartTime: ' . $outage->starttime);
|
||||
header('X-Outage-EndTime: ' . $outage->stoptime);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user