View | Details | Raw Unified | Return to bug 62849
Collapse All | Expand All

(-)src/main/org/apache/tools/ant/DirectoryScanner.java (+11 lines)
Lines 1258-1263 Link Here
1258
            final String name = vpath + newFile;
1258
            final String name = vpath + newFile;
1259
            final TokenizedPath newPath = new TokenizedPath(path, newFile);
1259
            final TokenizedPath newPath = new TokenizedPath(path, newFile);
1260
            final File file = new File(dir, newFile);
1260
            final File file = new File(dir, newFile);
1261
1262
            try {
1263
                if (FileUtils.getFileUtils().isLeadingPath(file.getAbsoluteFile(),
1264
                    dir.getAbsoluteFile(), true)) {
1265
                    continue;
1266
                }
1267
            } catch (IOException e) {
1268
                System.err.println("Failed to get canoncial paths to determine " +
1269
                    "if filesyste loop exists, continuning");
1270
            }
1271
1261
            final String[] children = file.list();
1272
            final String[] children = file.list();
1262
            if (children == null || (children.length == 0 && file.isFile())) {
1273
            if (children == null || (children.length == 0 && file.isFile())) {
1263
                if (isIncluded(newPath)) {
1274
                if (isIncluded(newPath)) {
(-)src/etc/testcases/core/directoryscanner.xml (+5 lines)
Lines 38-41 Link Here
38
        <touch file="${output}/alpha/beta/gamma/gamma.xml"/>
38
        <touch file="${output}/alpha/beta/gamma/gamma.xml"/>
39
    </target>
39
    </target>
40
40
41
    <target name="symlink-nested-setup" depends="setUp">
42
        <symlink link="${output}/alpha/beta/gamma/beta-link" resource="${output}/alpha/beta"/>
43
        <touch file="${output}/alpha/beta/gamma/gamma.xml"/>
44
    </target>
45
41
</project>
46
</project>
(-)src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java (+14 lines)
Lines 132-137 Link Here
132
                new String[] {"alpha/beta/gamma"});
132
                new String[] {"alpha/beta/gamma"});
133
    }
133
    }
134
134
135
    @Test
136
    public void testAllowRecursiveSymlinks() {
137
138
        assumeTrue("Current system does not support Symlinks", supportsSymlinks);
139
140
        buildRule.getProject().executeTarget("symlink-nested-setup");
141
        DirectoryScanner ds = new DirectoryScanner();
142
        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
143
        ds.setIncludes(new String[] {"alpha/beta/gamma/"});
144
        ds.scan();
145
        compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"},
146
            new String[] {"alpha/beta/gamma"});
147
    }
148
135
    @Test
149
    @Test
136
    public void testProhibitSymlinks() {
150
    public void testProhibitSymlinks() {
137
        assumeTrue("Current system does not support Symlinks", supportsSymlinks);
151
        assumeTrue("Current system does not support Symlinks", supportsSymlinks);
(-)src/main/org/apache/tools/ant/taskdefs/Delete.java (-1 / +11 lines)
Lines 19-24 Link Here
19
package org.apache.tools.ant.taskdefs;
19
package org.apache.tools.ant.taskdefs;
20
20
21
import java.io.File;
21
import java.io.File;
22
import java.io.IOException;
22
import java.util.Arrays;
23
import java.util.Arrays;
23
import java.util.Comparator;
24
import java.util.Comparator;
24
import java.util.Iterator;
25
import java.util.Iterator;
Lines 771-777 Link Here
771
        }
772
        }
772
        for (String s : list) {
773
        for (String s : list) {
773
            File f = new File(d, s);
774
            File f = new File(d, s);
774
            if (f.isDirectory()) {
775
776
            boolean isSymlink = false;
777
778
            try {
779
                isSymlink = SYMLINK_UTILS.isSymbolicLink(f);
780
            } catch (IOException e) {
781
                log("Failed to check directory is symlink, assuming that it is not");
782
            }
783
784
            if (!isSymlink && f.isDirectory()) {
775
                removeDir(f);
785
                removeDir(f);
776
            } else {
786
            } else {
777
                log("Deleting " + f.getAbsolutePath(), quiet ? Project.MSG_VERBOSE : verbosity);
787
                log("Deleting " + f.getAbsolutePath(), quiet ? Project.MSG_VERBOSE : verbosity);

Return to bug 62849