Skip to content

Commit

Permalink
MDL-51016 messaging: Fix email attachments on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
micaherne committed Aug 6, 2015
1 parent 57739a7 commit 80dfcf4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 80dfcf4

Please sign in to comment.