@@ -571,7 +571,9 @@ public function cutFile($row, $href, $label, $title, $icon, $attributes)
571
571
*/
572
572
public function deleteFile ($ row , $ href , $ label , $ title , $ icon , $ attributes )
573
573
{
574
- if (is_dir (TL_ROOT . '/ ' . $ row ['id ' ]) && count (scan (TL_ROOT . '/ ' . $ row ['id ' ])) > 0 )
574
+ $ path = TL_ROOT . '/ ' . urldecode ($ row ['id ' ]);
575
+
576
+ if (is_dir ($ path ) && count (scan ($ path )) > 0 )
575
577
{
576
578
return $ this ->User ->hasAccess ('f4 ' , 'fop ' ) ? '<a href=" ' .$ this ->addToUrl ($ href .'&id= ' .$ row ['id ' ]).'" title=" ' .specialchars ($ title , false , true ).'" ' .$ attributes .'> ' .Image::getHtml ($ icon , $ label ).'</a> ' : Image::getHtml (preg_replace ('/\.gif$/i ' , '_.gif ' , $ icon )).' ' ;
577
579
}
@@ -653,13 +655,23 @@ public function showFile($row, $href, $label, $title, $icon, $attributes)
653
655
*/
654
656
public function protectFolder (DataContainer $ dc )
655
657
{
656
- $ count = 0 ;
657
658
$ strPath = $ dc ->id ;
658
659
659
660
// Check whether the temporary name has been replaced already (see #6432)
660
- if (Input::post ('name ' ) && ( $ strNewPath = str_replace ( ' __new__ ' , Input:: post ( ' name ' ), $ strPath , $ count )) && $ count > 0 && is_dir ( TL_ROOT . ' / ' . $ strNewPath ) )
661
+ if (Input::post ('name ' ))
661
662
{
662
- $ strPath = $ strNewPath ;
663
+ if (Validator::isInsecurePath (Input::post ('name ' )))
664
+ {
665
+ throw new RuntimeException ('Invalid file or folder name ' . Input::post ('name ' ));
666
+ }
667
+
668
+ $ count = 0 ;
669
+ $ strName = basename ($ strPath );
670
+
671
+ if (($ strNewPath = str_replace ($ strName , Input::post ('name ' ), $ strPath , $ count )) && $ count > 0 && is_dir (TL_ROOT . '/ ' . $ strNewPath ))
672
+ {
673
+ $ strPath = $ strNewPath ;
674
+ }
663
675
}
664
676
665
677
// Only show for folders (see #5660)
0 commit comments