From 80dfcf49f58ad22e6ab51b6078df4a6e92c32ae3 Mon Sep 17 00:00:00 2001 From: Michael Aherne Date: Thu, 6 Aug 2015 12:53:17 +0100 Subject: [PATCH] MDL-51016 messaging: Fix email attachments on Windows --- lib/moodlelib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 72b62b0cf7f..a91cab451f4 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5617,11 +5617,11 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '', // Before doing the comparison, make sure that the paths are correct (Windows uses slashes in the other direction). $attachpath = str_replace('\\', '/', $attachmentpath); // Make sure both variables are normalised before comparing. - $temppath = str_replace('\\', '/', $CFG->tempdir); + $temppath = str_replace('\\', '/', realpath($CFG->tempdir)); // If the attachment is a full path to a file in the tempdir, use it as is, // otherwise assume it is a relative path from the dataroot (for backwards compatibility reasons). - if (strpos($attachpath, realpath($temppath)) !== 0) { + if (strpos($attachpath, $temppath) !== 0) { $attachmentpath = $CFG->dataroot . '/' . $attachmentpath; }