Browse Source

PathTokenizer didn't deal correctly with ../ style relative paths

following a colon in Unix style PATH structures on Netware.

Submitted by:	Jeff Tulley <JTULLEY at novell dot com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274829 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
d1bb5df72d
2 changed files with 28 additions and 3 deletions
  1. +4
    -2
      src/main/org/apache/tools/ant/PathTokenizer.java
  2. +24
    -1
      src/testcases/org/apache/tools/ant/types/PathTest.java

+ 4
- 2
src/main/org/apache/tools/ant/PathTokenizer.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000,2002 The Apache Software Foundation. All rights
* Copyright (c) 2000,2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -176,7 +176,9 @@ public class PathTokenizer {
// make sure we aren't going to get the path separator next
if (!nextToken.equals(File.pathSeparator)) {
if (nextToken.equals(":")) {
if (!token.startsWith("/") && !token.startsWith("\\")) {
if (!token.startsWith("/") && !token.startsWith("\\")
&& !token.startsWith(".")
&& !token.startsWith("..")) {
// it indeed is a drive spec, get the next bit
String oneMore = tokenizer.nextToken().trim();
if (!oneMore.equals(File.pathSeparator)) {


+ 24
- 1
src/testcases/org/apache/tools/ant/types/PathTest.java View File

@@ -1,7 +1,7 @@
/*
* 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.
*
* Redistribution and use in source and binary forms, with or without
@@ -104,6 +104,29 @@ public class PathTest extends TestCase {
}
}

public void testRelativePathUnixStyle() {
project.setBasedir("src/etc");
Path p = new Path(project, "..:testcases");
String[] l = p.list();
assertEquals("two items, Unix style", 2, l.length);
if (isUnixStyle) {
assertTrue("test resolved relative to src/etc",
l[0].endsWith("/src"));
assertTrue("test resolved relative to src/etc",
l[1].endsWith("/src/etc/testcases"));
} else if (isNetWare) {
assertTrue("test resolved relative to src/etc",
l[0].endsWith("\\src"));
assertTrue("test resolved relative to src/etc",
l[1].endsWith("\\src\\etc\\testcases"));
} else {
assertTrue("test resolved relative to src/etc",
l[0].endsWith("\\src"));
assertTrue("test resolved relative to src/etc",
l[1].endsWith("\\src\\etc\\testcases"));
}
}

public void testConstructorWindowsStyle() {
Path p = new Path(project, "\\a;\\b");
String[] l = p.list();


Loading…
Cancel
Save