diff --git a/lib/file-control.php b/lib/file-control.php index d8391c8..ec6c506 100644 --- a/lib/file-control.php +++ b/lib/file-control.php @@ -15,9 +15,15 @@ $file = str_replace("|","/",strClean( : $_GET['file'] )); +// Put the original $file var aside for use +$fileOrig = $file; + // Trim any +'s or spaces from the end of file $file = rtrim(rtrim($file,'+'),' '); +// Also remove [NEW] from $file, we can consider $_GET['action'] or $fileOrig to pick that up +$file = rtrim($file,'[NEW]'); + // Make each path in $file a full path (; seperated list) $allFiles = explode(";",$file); for ($i=0; $i"); + // A local folder that isn't the doc root or starts with the doc root + ($_GET['action']!="getRemoteFile" && + rtrim($allFiles[$i],"/") !== rtrim($docRoot,"/") && + strpos(realpath(rtrim(dirname($allFiles[$i]),"/")),realpath(rtrim($docRoot,"/"))) !== 0 + ) || + // Or a remote URL that doesn't start http + ($_GET['action']=="getRemoteFile" && strpos($allFiles[$i],"http") !== 0) + ) { + die("alert('Sorry! - problem with file requested');"); }; } -// Uncomment to alert and console.log the action and file, useful for debugging -// echo ";alert('".xssClean($_GET['action'],"html")." : ".$file."');console.log('".xssClean($_GET['action'],"html")." : ".$file."');"; - // If we're due to open a file... if ($_GET['action']=="load") { echo 'action="load";'; @@ -461,7 +473,7 @@ if (action=="load") {