Browse Source

TarEntry's File-constructor didn't work for many OSes.

PR: 18105

At the same time, make the OS check Locale independent.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274286 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
d64034d24e
2 changed files with 9 additions and 6 deletions
  1. +4
    -0
      WHATSNEW
  2. +5
    -6
      src/main/org/apache/tools/tar/TarEntry.java

+ 4
- 0
WHATSNEW View File

@@ -66,6 +66,10 @@ Fixed bugs:
* <exec> output and error streams can now be redirected independently * <exec> output and error streams can now be redirected independently
to either a property or a file (or both) to either a property or a file (or both)


* TarEntry's File-arg constructor would fail with a
StringIndexOutOfBoundsException on all OSes where os.name is shorter
than seven characters. Bugzilla Report 18105.

Other changes: Other changes:
-------------- --------------
* The filesetmanifest attribute of <jar> has been reenabled. * The filesetmanifest attribute of <jar> has been reenabled.


+ 5
- 6
src/main/org/apache/tools/tar/TarEntry.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,7 @@ package org.apache.tools.tar;


import java.io.File; import java.io.File;
import java.util.Date; import java.util.Date;
import java.util.Locale;


/** /**
* This class represents an entry in a Tar archive. It consists * This class represents an entry in a Tar archive. It consists
@@ -200,16 +201,14 @@ public class TarEntry implements TarConstants {
this.file = file; this.file = file;
String name = file.getPath(); String name = file.getPath();
String osname = System.getProperty("os.name");
String osname = System.getProperty("os.name").toLowerCase(Locale.US);
if (osname != null) { if (osname != null) {
// Strip off drive letters! // Strip off drive letters!
// REVIEW Would a better check be "(File.separator == '\')"? // REVIEW Would a better check be "(File.separator == '\')"?
String win32Prefix = "Windows";
String prefix = osname.substring(0, win32Prefix.length());
if (prefix.equalsIgnoreCase(win32Prefix)) {
if (osname.startsWith("windows")) {
if (name.length() > 2) { if (name.length() > 2) {
char ch1 = name.charAt(0); char ch1 = name.charAt(0);
char ch2 = name.charAt(1); char ch2 = name.charAt(1);
@@ -220,7 +219,7 @@ public class TarEntry implements TarConstants {
name = name.substring(2); name = name.substring(2);
} }
} }
} else if (osname.toLowerCase().indexOf("netware") > -1) {
} else if (osname.indexOf("netware") > -1) {
int colon = name.indexOf(':'); int colon = name.indexOf(':');
if (colon != -1) { if (colon != -1) {
name = name.substring(colon + 1); name = name.substring(colon + 1);


Loading…
Cancel
Save