bodewig     01/02/20 03:20:16

  Modified:    src/etc/testcases/taskdefs Tag: ANT_13_BRANCH zip.xml
               src/main/org/apache/tools/ant/taskdefs Tag: ANT_13_BRANCH
                        Zip.java
               src/testcases/org/apache/tools/ant/taskdefs Tag:
                        ANT_13_BRANCH ZipTest.java
  Log:
  Throw an exception if a zip file is going to be included in itself
  because it becomes part of the fileset after the task starts.
  
  PR: 564
  Submitted by: David Rees <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.2   +14 -3     jakarta-ant/src/etc/testcases/taskdefs/zip.xml
  
  Index: zip.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/zip.xml,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- zip.xml   2001/02/19 13:30:06     1.2.2.1
  +++ zip.xml   2001/02/20 11:20:03     1.2.2.2
  @@ -10,13 +10,24 @@
       <zip zipfile="zip.tmp"/>
     </target>
   
  +  <!-- Test when the zip file includes itself
  +  when target file exists before the zip task is run -->
     <target name="test3">
       <touch file="test3.zip"/>
  -    <tar zipfile="test3.zip"
  +    <zip zipfile="test3.zip"
            basedir="."/>
     </target>
  -  
  -  <target name="cleanup"> 
  +
  +  <!-- Test when the zip file includes itself
  +  when target file does not exist before the zip task is run -->
  +  <target name="test4">
  +     <zip zipfile="test4.zip"
  +         basedir="."/>
  +  </target>
  +
  +
  +  <target name="cleanup">
       <delete file="test3.zip"/>
  +    <delete file="test4.zip"/>
     </target>
   </project>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.30.2.2  +4 -0      
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java
  
  Index: Zip.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
  retrieving revision 1.30.2.1
  retrieving revision 1.30.2.2
  diff -u -r1.30.2.1 -r1.30.2.2
  --- Zip.java  2001/02/19 13:30:07     1.30.2.1
  +++ Zip.java  2001/02/20 11:20:08     1.30.2.2
  @@ -465,6 +465,10 @@
       protected void zipFile(File file, ZipOutputStream zOut, String vPath)
           throws IOException
       {
  +        if (file.equals(zipFile)) {
  +            throw new BuildException("A zip file cannot include itself", 
location);
  +        }
  +
           FileInputStream fIn = new FileInputStream(file);
           try {
               zipFile(fIn, zOut, vPath, file.lastModified());
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.2   +4 -0      
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
  
  Index: ZipTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- ZipTest.java      2001/02/19 13:30:07     1.2.2.1
  +++ ZipTest.java      2001/02/20 11:20:13     1.2.2.2
  @@ -78,6 +78,10 @@
       public void test3() { 
           expectBuildException("test3", "zip cannot include itself");
       }
  +
  +    public void test4() { 
  +        expectBuildException("test4", "zip cannot include itself");
  +    }
       
       public void tearDown() {
           executeTarget("cleanup");
  
  
  

Reply via email to