fix uploading files to folders with special characters in the name

This commit is contained in:
Robin Appelman 2010-10-24 13:25:21 +02:00
parent e56c316576
commit b116b2fd4c
2 changed files with 3 additions and 5 deletions

4
files/upload.php Normal file → Executable file
View File

@ -22,11 +22,9 @@
*/
require_once('../inc/lib_base.php');
// sleep(5); //immitate slow internet.
$fileName=$_FILES['file']['name'];
$source=$_FILES['file']['tmp_name'];
$target=$_GET['dir'].'/'.$fileName;
$target=stripslashes($_GET['dir']).'/'.$fileName;
if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($_GET['dir'],'..')===false){
if(OC_FILESYSTEM::fromTmpFile($source,$target)){
echo 'true';

View File

@ -310,7 +310,7 @@ OC_FILES.browser.show_callback=function(content){
OC_FILES.browser.files.show(null,content);
}
if(OC_FILES.uploadForm){
OC_FILES.uploadForm.setAttribute('action','files/upload.php?dir='+dir);
OC_FILES.uploadForm.setAttribute('action','files/upload.php?dir='+encodeURIComponent(dir));
}
}
@ -423,7 +423,7 @@ OC_FILES.browser.showuploader=function(dir,parent,max_upload){
var iframeId=OC_FILES.uploadIFrames.length
OC_FILES.uploadForm=document.createElement('form');
OC_FILES.uploadForm.setAttribute('target','uploadIFrame'+iframeId);
OC_FILES.uploadForm.setAttribute('action','files/upload.php?dir='+dir);
OC_FILES.uploadForm.setAttribute('action','files/upload.php?dir='+encodeURIComponent(dir));
OC_FILES.uploadForm.method='post';
OC_FILES.uploadForm.setAttribute('enctype','multipart/form-data');
OC_FILES.uploadIFrames[iframeId]=document.createElement('iframe');