diff --git a/WHATSNEW b/WHATSNEW index 82f78ac6f..187bd2b23 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -81,6 +81,9 @@ Fixed bugs: when tasks spawned new child threads that accessed the properties. Bugzilla Report 55074 + * TarArchiveEntry's constructor with a File and a String arg didn't + normalize the name. + Other changes: -------------- diff --git a/src/main/org/apache/tools/tar/TarEntry.java b/src/main/org/apache/tools/tar/TarEntry.java index 0bfc92673..dc9b64e02 100644 --- a/src/main/org/apache/tools/tar/TarEntry.java +++ b/src/main/org/apache/tools/tar/TarEntry.java @@ -257,7 +257,7 @@ public class TarEntry implements TarConstants { * @param file The file that the entry represents. */ public TarEntry(File file) { - this(file, normalizeFileName(file.getPath(), false)); + this(file, file.getPath()); } /** @@ -270,6 +270,7 @@ public class TarEntry implements TarConstants { public TarEntry(File file, String fileName) { this(); + String normalizedName = normalizeFileName(fileName, false); this.file = file; this.linkName = ""; @@ -278,18 +279,18 @@ public class TarEntry implements TarConstants { this.mode = DEFAULT_DIR_MODE; this.linkFlag = LF_DIR; - int nameLength = fileName.length(); - if (nameLength == 0 || fileName.charAt(nameLength - 1) != '/') { - this.name = fileName + "/"; + int nameLength = normalizedName.length(); + if (nameLength == 0 || normalizedName.charAt(nameLength - 1) != '/') { + this.name = normalizedName + "/"; } else { - this.name = fileName; + this.name = normalizedName; } this.size = 0; } else { this.mode = DEFAULT_FILE_MODE; this.linkFlag = LF_NORMAL; this.size = file.length(); - this.name = fileName; + this.name = normalizedName; } this.modTime = file.lastModified() / MILLIS_PER_SECOND;