Skip to content

Commit f46f2fa

Browse files
authored
Merge pull request #1426 from brendandburns/apply
Add path normalization for archive files.
2 parents 08c9a0f + ff16217 commit f46f2fa

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<apache.commons.lang3.version>3.11</apache.commons.lang3.version>
5959
<apache.commons.collections4.version>4.4</apache.commons.collections4.version>
6060
<apache.commons.compress>1.20</apache.commons.compress>
61+
<apache.commons.io>2.8.0</apache.commons.io>
6162
<common.codec.version>1.15</common.codec.version>
6263
<spring.boot.version>2.3.5.RELEASE</spring.boot.version>
6364
<spring.version>5.2.9.RELEASE</spring.version>
@@ -113,6 +114,11 @@
113114
<artifactId>commons-compress</artifactId>
114115
<version>${apache.commons.compress}</version>
115116
</dependency>
117+
<dependency>
118+
<groupId>commons-io</groupId>
119+
<artifactId>commons-io</artifactId>
120+
<version>${apache.commons.io}</version>
121+
</dependency>
116122
<dependency>
117123
<groupId>com.github.ben-manes.caffeine</groupId>
118124
<artifactId>caffeine</artifactId>

util/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
<groupId>org.apache.commons</groupId>
4747
<artifactId>commons-lang3</artifactId>
4848
</dependency>
49+
<dependency>
50+
<groupId>commons-io</groupId>
51+
<artifactId>commons-io</artifactId>
52+
</dependency>
4953
<dependency>
5054
<groupId>org.slf4j</groupId>
5155
<artifactId>slf4j-api</artifactId>

util/src/main/java/io/kubernetes/client/Copy.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
4343
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
4444
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
45+
import org.apache.commons.io.FilenameUtils;
4546
import org.slf4j.Logger;
4647
import org.slf4j.LoggerFactory;
4748

@@ -188,7 +189,11 @@ public Future<Integer> copyDirectoryFromPodAsync(
188189
log.error("Can't read: " + entry);
189190
continue;
190191
}
191-
File f = new File(destination.toFile(), entry.getName());
192+
String normalName = FilenameUtils.normalize(entry.getName());
193+
if (normalName == null) {
194+
throw new IOException("Invalid entry: " + entry.getName());
195+
}
196+
File f = new File(destination.toFile(), normalName);
192197
if (entry.isDirectory()) {
193198
if (!f.isDirectory() && !f.mkdirs()) {
194199
throw new IOException("create directory failed: " + f);

0 commit comments

Comments
 (0)