Skip to content

Commit

Permalink
MDL-26028 fix invalid separator constant and support root dirs in ali…
Browse files Browse the repository at this point in the history
…ases

Credit goes to Loic Jeannin, thanks.
  • Loading branch information
skodak committed Apr 30, 2012
1 parent f7d26a0 commit e61f888
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/xsendfilelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ function xsendfile($filepath) {
$aliased = false;
if (!empty($CFG->xsendfilealiases) and is_array($CFG->xsendfilealiases)) {
foreach ($CFG->xsendfilealiases as $alias=>$dir) {
$dir = realpath($dir).PATH_SEPARATOR;
$dir = realpath($dir);
if ($dir === false) {
continue;
}
if (substr($dir, -1) !== DIRECTORY_SEPARATOR) {
// add trailing dir separator
$dir .= DIRECTORY_SEPARATOR;
}
if (strpos($filepath, $dir) === 0) {
$filepath = $alias.substr($filepath, strlen($dir));
$aliased = true;
Expand Down

0 comments on commit e61f888

Please sign in to comment.