Skip to content

Commit

Permalink
fix: skip files if cleaned to empty filename (#3166)
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches authored Jul 18, 2023
1 parent ba2f128 commit 3fdc06a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions brut.j.dir/src/main/java/brut/directory/DirUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ public static void copyToDir(Directory in, File out, String fileName)
// Skip copies of directories/files not found.
} else {
String cleanedFilename = BrutIO.sanitizeUnknownFile(out, fileName);
File outFile = new File(out, cleanedFilename);
//noinspection ResultOfMethodCallIgnored
outFile.getParentFile().mkdirs();
BrutIO.copyAndClose(in.getFileInput(fileName), Files.newOutputStream(outFile.toPath()));
if (! cleanedFilename.isEmpty()) {
File outFile = new File(out, cleanedFilename);
//noinspection ResultOfMethodCallIgnored
outFile.getParentFile().mkdirs();
BrutIO.copyAndClose(in.getFileInput(fileName), Files.newOutputStream(outFile.toPath()));
}
}
} catch (RootUnknownFileException | InvalidUnknownFileException | TraversalUnknownFileException exception) {
LOGGER.warning(String.format("Skipping file %s (%s)", fileName, exception.getMessage()));
Expand Down

0 comments on commit 3fdc06a

Please sign in to comment.