Skip to content

Commit

Permalink
Ad-hoc DB queries: form validation messages not properly escaped #503283
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Sep 23, 2021
1 parent bfc938b commit 05b24f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ public function validation($data, $files) {
$rs->close();
} catch (dml_exception $e) {
$errors['querysql'] = get_string('queryfailed', 'report_customsql',
$e->getMessage() . ' ' . $e->debuginfo);
s($e->getMessage() . ' ' . $e->debuginfo));
} catch (Exception $e) {
$errors['querysql'] = get_string('queryfailed', 'report_customsql',
$e->getMessage());
s($e->getMessage()));
}
}
}
Expand All @@ -266,29 +266,29 @@ public function validation($data, $files) {
// The path either needs to be a writable directory ...
if (is_dir($path) ) {
if (!is_writable($path)) {
$errors['customdir'] = get_string('customdirnotwritable', 'report_customsql', $path);
$errors['customdir'] = get_string('customdirnotwritable', 'report_customsql', s($path));
}

} else if (substr($path, -1) == DIRECTORY_SEPARATOR) {
// ... and it must exist...
$errors['customdir'] = get_string('customdirmustexist', 'report_customsql', $path);
$errors['customdir'] = get_string('customdirmustexist', 'report_customsql', s($path));

} else {

// ... or be a path to a writable file, or a new file in a writable directory.
$dir = dirname($path);

if (!is_dir($dir)) {
$errors['customdir'] = get_string('customdirnotadirectory', 'report_customsql', $dir);
$errors['customdir'] = get_string('customdirnotadirectory', 'report_customsql', s($dir));
} else {

if (file_exists($path)) {
if (!is_writable($path)) {
$errors['customdir'] = get_string('filenotwritable', 'report_customsql', $path);
$errors['customdir'] = get_string('filenotwritable', 'report_customsql', s($path));
}
} else {
if (!is_writable($dir)) {
$errors['customdir'] = get_string('customdirmustexist', 'report_customsql', $dir);
$errors['customdir'] = get_string('customdirmustexist', 'report_customsql', s($dir));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ function report_customsql_validate_users($userids, $capability) {
// User does not have the chosen access level.
$context = context_user::instance($user->id);
$a->userid = $userid;
$a->name = fullname($user);
$a->name = s(fullname($user));
if (!has_capability($capability, $context, $user)) {
return get_string('userhasnothiscapability', 'report_customsql', $a);
}
Expand Down

0 comments on commit 05b24f4

Please sign in to comment.