in src/main/java/org/apache/shenyu/util/FileUtil.java [35:67]
public static void unTarGz(String tarGzFilePath, String destDir) {
Path source = Paths.get(tarGzFilePath);
Path target = Paths.get(destDir);
try (InputStream fi = Files.newInputStream(source);
BufferedInputStream bi = new BufferedInputStream(fi);
GzipCompressorInputStream gzi = new GzipCompressorInputStream(bi);
TarArchiveInputStream ti = new TarArchiveInputStream(gzi)) {
ArchiveEntry entry;
while ((entry = ti.getNextEntry()) != null) {
Path newPath = zipSlipProtect(entry, target);
if (entry.isDirectory()) {
Files.createDirectories(newPath);
} else {
Path parent = newPath.getParent();
if (parent != null) {
if (Files.notExists(parent)) {
Files.createDirectories(parent);
}
}
Files.copy(ti, newPath, StandardCopyOption.REPLACE_EXISTING);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}