fix: skip files if cleaned to empty filename (#3166)

This commit is contained in:
Connor Tumbleson 2023-07-18 07:26:30 -04:00 committed by GitHub
parent ba2f1283ed
commit 3fdc06a46f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,11 +89,13 @@ public class DirUtil {
// Skip copies of directories/files not found. // Skip copies of directories/files not found.
} else { } else {
String cleanedFilename = BrutIO.sanitizeUnknownFile(out, fileName); String cleanedFilename = BrutIO.sanitizeUnknownFile(out, fileName);
if (! cleanedFilename.isEmpty()) {
File outFile = new File(out, cleanedFilename); File outFile = new File(out, cleanedFilename);
//noinspection ResultOfMethodCallIgnored //noinspection ResultOfMethodCallIgnored
outFile.getParentFile().mkdirs(); outFile.getParentFile().mkdirs();
BrutIO.copyAndClose(in.getFileInput(fileName), Files.newOutputStream(outFile.toPath())); BrutIO.copyAndClose(in.getFileInput(fileName), Files.newOutputStream(outFile.toPath()));
} }
}
} catch (RootUnknownFileException | InvalidUnknownFileException | TraversalUnknownFileException exception) { } catch (RootUnknownFileException | InvalidUnknownFileException | TraversalUnknownFileException exception) {
LOGGER.warning(String.format("Skipping file %s (%s)", fileName, exception.getMessage())); LOGGER.warning(String.format("Skipping file %s (%s)", fileName, exception.getMessage()));
} catch (IOException | BrutException ex) { } catch (IOException | BrutException ex) {