This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push: new cefdd55 Null-guard and fix lower case. Fix typo. cefdd55 is described below commit cefdd552695462b81c3a57f072bd1ceda263e34b Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Feb 19 19:42:02 2022 -0500 Null-guard and fix lower case. Fix typo. --- .../compress/archivers/tar/TarArchiveEntry.java | 39 +++++++++++----------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java index 9d906d4..b722568 100644 --- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java +++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java @@ -1699,32 +1699,31 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO } /** - * Strips Windows' drive letter as well as any leading slashes, - * turns path separators into forward slahes. + * Strips Windows' drive letter as well as any leading slashes, turns path separators into forward slashes. */ - private static String normalizeFileName(String fileName, - final boolean preserveAbsolutePath) { + private static String normalizeFileName(String fileName, final boolean preserveAbsolutePath) { if (!preserveAbsolutePath) { - final String osname = System.getProperty("os.name").toLowerCase(Locale.ENGLISH); + final String property = System.getProperty("os.name"); + if (property != null) { + final String osName = property.toLowerCase(Locale.ROOT); - // Strip off drive letters! - // REVIEW Would a better check be "(File.separator == '\')"? + // Strip off drive letters! + // REVIEW Would a better check be "(File.separator == '\')"? - if (osname.startsWith("windows")) { - if (fileName.length() > 2) { - final char ch1 = fileName.charAt(0); - final char ch2 = fileName.charAt(1); + if (osName.startsWith("windows")) { + if (fileName.length() > 2) { + final char ch1 = fileName.charAt(0); + final char ch2 = fileName.charAt(1); - if (ch2 == ':' - && (ch1 >= 'a' && ch1 <= 'z' - || ch1 >= 'A' && ch1 <= 'Z')) { - fileName = fileName.substring(2); + if (ch2 == ':' && (ch1 >= 'a' && ch1 <= 'z' || ch1 >= 'A' && ch1 <= 'Z')) { + fileName = fileName.substring(2); + } + } + } else if (osName.contains("netware")) { + final int colon = fileName.indexOf(':'); + if (colon != -1) { + fileName = fileName.substring(colon + 1); } - } - } else if (osname.contains("netware")) { - final int colon = fileName.indexOf(':'); - if (colon != -1) { - fileName = fileName.substring(colon + 1); } } }