@@ -405,9 +405,9 @@ public function searchFiles($filepattern, $start_dir)
405
405
public function CheckParams ()
406
406
{
407
407
// recuperation des parametres necessaire
408
- $ this ->file = $ this ->wiki ->GetParameter ('attachfile ' );
408
+ $ this ->file = htmlspecialchars ( $ this ->wiki ->GetParameter ('attachfile ' ) );
409
409
if (empty ($ this ->file )) {
410
- $ this ->file = $ this ->wiki ->GetParameter ('file ' );
410
+ $ this ->file = htmlspecialchars ( $ this ->wiki ->GetParameter ('file ' ) );
411
411
}
412
412
413
413
$ this ->desc = $ this ->wiki ->GetParameter ('attachdesc ' );
@@ -723,15 +723,19 @@ public function doUpload()
723
723
*/
724
724
public function showUploadForm ()
725
725
{
726
- $ this ->file = $ _GET ['file ' ];
727
- echo '<h3> ' . _t ('ATTACH_UPLOAD_FORM_FOR_FILE ' ) . ' ' . $ this ->file . "</h3> \n" ;
728
- echo '<form enctype="multipart/form-data" name="frmUpload" method="POST" action=" ' . $ this ->wiki ->href ('upload ' , $ this ->wiki ->GetPageTag ()) . "\"> \n"
726
+ $ this ->file = realpath (filter_input (INPUT_GET , 'file ' , FILTER_SANITIZE_FULL_SPECIAL_CHARS ));
727
+ if (!empty ($ this ->file )) {
728
+ echo '<h3> ' . _t ('ATTACH_UPLOAD_FORM_FOR_FILE ' ) . ' ' . $ this ->file . "</h3> \n" ;
729
+ echo '<form enctype="multipart/form-data" name="frmUpload" method="POST" action=" ' . $ this ->wiki ->href ('upload ' , $ this ->wiki ->GetPageTag ()) . "\"> \n"
729
730
. ' <input type="hidden" name="wiki" value=" ' . $ this ->wiki ->GetPageTag () . "/upload \" /> \n"
730
731
. ' <input type="hidden" name="MAX_FILE_SIZE" value=" ' . $ this ->attachConfig ['max_file_size ' ] . "\" /> \n"
731
732
. " <input type= \"hidden \" name= \"file \" value= \"$ this ->file \" /> \n"
732
733
. " <input type= \"file \" name= \"upFile \" size= \"50 \" /><br /> \n"
733
734
. ' <input class="btn btn-primary" type="submit" value=" ' . _t ('ATTACH_SAVE ' ) . "\" /> \n"
734
735
. "</form> \n" ;
736
+ } else {
737
+ echo '<div class="alert alert-danger">No valid filename</div> ' ;
738
+ }
735
739
}
736
740
737
741
/**
@@ -741,7 +745,7 @@ public function performUpload()
741
745
{
742
746
$ this ->file = $ _POST ['file ' ];
743
747
$ pathinfo = pathinfo ($ this ->file );
744
- $ ext = strtolower ($ pathinfo ['extension ' ]);
748
+ $ ext = strtolower ($ pathinfo ['extension ' ] ?? '' );
745
749
if ($ this ->wiki ->config ['authorized-extensions ' ] && !in_array ($ ext , array_keys ($ this ->wiki ->config ['authorized-extensions ' ]))) {
746
750
$ _FILES ['upFile ' ]['error ' ] = 5 ;
747
751
}
0 commit comments