Issue Details (XML | Word | Printable)

Key: EMAIL-49
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Niall Pemberton
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Email

[Email] Compatability With JavaMail 1.2

Created: 07/Sep/05 12:53 PM   Updated: 16/May/06 12:09 PM
Return to search
Component/s: None
Affects Version/s: Nightly Builds
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Text File commons-email-validate.txt 2005-09-07 12:56 PM Niall Pemberton 0.8 kB
Java Source File InvalidInternetAddressTest.java 2005-09-07 01:29 PM Niall Pemberton 7 kB
Environment:
Operating System: other
Platform: Other

Bugzilla Id: 36536


 Description  « Hide
The InternetAddress.validate() method is the only version 1.3 feature of
JavaMail used in commons-email. Removing its use means that commons-email will
compile (and tests run) against JavaMail 1.2

This ticket is as a result of this thread on the user list:

http://www.mail-archive.com/commons-user%40jakarta.apache.org/msg12817.html

However some of the assertions I made there were incorrect.

JavaMail 1.3 introduced the facility to specify a strict=false setting when
parsing an InternetAddress and a new validate() method to check whether
a "loosley parsed" InternetAddress was valid.

I made a mistake in that thread. The Email class uses the following
constructors:

InternetAdress(String address, String personal)
InternetAdress(String address, String personal, String charset)

These constructors assume the "address" is a valid RFC822 internet address and
don't "validate" them. Therefore Email as its currently coded is correct to
then call the validate() method.

However the following constructor does validate...

InternetAdress(String address)

... and I'm attaching a patch which removes the need to use the validate()
method.

However its not quite that simple. Since the validate() method in JavaMail 1.3
isn't "as strict" as the above constructor - which is compatible with JavaMail
1.2 - it doesn't validate addresses which contain quotes or '[' at all.
Therefore applying the patch will make it 1.2 compatible, but also make the
validation stricter.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Niall Pemberton added a comment - 07/Sep/05 12:56 PM
Created an attachment (id=16324)
Patch for org.apache.commons.email.Email

This patch changes the Email class to use the InternetAdress(address)
constructor (which validates) and removes the use of the
InternetAddress.validate() method - maiking it compatible with JavaMail 1.2


Niall Pemberton added a comment - 07/Sep/05 01:29 PM
Created an attachment (id=16325)
InvalidInternetAddressTest.java

Attached is a JUnit test case which demonstrates the differences in validation
in InternetAddress between:

1) using the constructor InternetAddress(address)
2) using the validate() method


Henning Schmiedehausen added a comment - 07/Sep/05 07:56 PM
Patch applied. I've added some dynamic code to the JUnit test to make sure that
it does not fail / still compiles using javamail 1.2.

Thanks a lot for the patch.