ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 15246] New: - EmailTask doesn't handle space in file paths
Date Tue, 10 Dec 2002 19:39:00 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15246>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15246

EmailTask doesn't handle space in file paths

           Summary: EmailTask doesn't handle space in file paths
           Product: Ant
           Version: 1.5.1
          Platform: Other
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: aaronj@norwestlabs.com


On line 365 of org.apache.tools.ant.taskdefs.email.EmailTask.java, the list of
filenames to attach is tokenized by comma (as per the documentation for the mail
task) and also by spaces. Unfortunately this seems to be preventing attaching
files with spaces in the pathname. I am using EmailTask directly from another
java application and attaching a file with spaces in the pathname causes a
NullPointerException to be thrown. I have not confirmed if doing the same using
the mail task from an ant build.xml has the same affect.

The following code has been tested and demonstrates the problem:

import org.apache.tools.ant.taskdefs.email.EmailTask;
import java.io.*;

public class TestEmailTask
{
    public static void main(String[] args)
    {
        try
        {
            EmailTask emailTask = new EmailTask();
            emailTask.setMailhost("myhost");
            emailTask.setMailport(25);
            emailTask.setSubject("Test");
            emailTask.setFrom("myself@somewhere.com");
            // Get NullPointerException on next line
            emailTask.setFiles("Path with spaces" + File.separator + "MyFile.txt");
            emailTask.execute();
        }
        catch (Throwable e)
        {
            e.printStackTrace();
        }
    }
}

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message