mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-70130 core: Compare realpaths for file attachment checks
Rather than using the provided path, the `realpath` must be used to ensure that the use of symlinks in paths is normalised.
This commit is contained in:
parent
4f22fad9ac
commit
c42c08793b
@ -6315,7 +6315,8 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '',
|
||||
$mimetype = mimeinfo('type', $attachname);
|
||||
|
||||
// Before doing the comparison, make sure that the paths are correct (Windows uses slashes in the other direction).
|
||||
$attachpath = str_replace('\\', '/', $attachment);
|
||||
// The absolute (real) path is also fetched to ensure that comparisons to allowed paths are compared equally.
|
||||
$attachpath = str_replace('\\', '/', realpath($attachment));
|
||||
|
||||
// Add allowed paths to an array (also check if it's not empty).
|
||||
$allowedpaths = array_filter([
|
||||
|
Loading…
x
Reference in New Issue
Block a user