File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
SequenceAnalysis/src/org/labkey/sequenceanalysis Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -435,8 +435,21 @@ public static class DownloadTempImageAction extends ExportAction<TempImageAction
435435 @ Override
436436 public void export (TempImageAction form , HttpServletResponse response , BindException errors ) throws Exception
437437 {
438- File parentDir = form .getDirectory () == null ? FileUtil .getTempDirectory () : new File (FileUtil .getTempDirectory (), form .getDirectory ());
439- File targetFile = new File (parentDir , form .getFileName ());
438+ File targetFile ;
439+ FileLike tempDirRoot = new FileSystemLike .Builder (FileUtil .getTempDirectory ()).root ();
440+ if (!(tempDirRoot .getFileSystem ().isDescendant (tempDirRoot , new File (form .getDirectory ()).toURI ())))
441+ {
442+ throw new FileNotFoundException ("Directory '" + form .getDirectory () + "' is not the descendant of '" + tempDirRoot .getFileSystem () + "'" );
443+ }
444+ FileLike parentDirFileLike = form .getDirectory () == null ? tempDirRoot : tempDirRoot .resolveFile (new Path (form .getDirectory ()));
445+ File parentDir = FileSystemLike .toFile (parentDirFileLike );
446+
447+ if (!(parentDirFileLike .getFileSystem ().isDescendant (parentDirFileLike , new File (form .getFileName ()).toURI ())))
448+ {
449+ throw new FileNotFoundException ("File '" + form .getFileName () + "' is not the descendant of '" + parentDirFileLike .getPath () + "'" );
450+ }
451+
452+ targetFile = FileSystemLike .toFile (parentDirFileLike .resolveChild (form .getFileName ()));
440453 targetFile = FileUtil .getAbsoluteCaseSensitiveFile (targetFile );
441454
442455 if (!NetworkDrive .exists (targetFile ))
You can’t perform that action at this time.
0 commit comments