commits@javamail.java.net

[javamail~mercurial:542] Merge with 1.4.7.

From: <shannon_at_kenai.com>
Date: Tue, 19 Mar 2013 03:19:06 +0000

Project: javamail
Repository: mercurial
Revision: 542
Author: shannon
Date: 2013-03-19 03:17:54 UTC
Link:

Log Message:
------------
Disable debug output in test.
Remove use of deprecated API, use TimeZone instead.
Fix bug in InternetAddress parsing that caused StringIndexOutOfBoundsException
when parsing an address with an unclosed double quote in the personal name.
Added a test for this case, and updated tests for other InternetAddress cases,
which required updating the test driver. Bug 5847.
Initialize the Service's URLName with the default host and user.
Merge with 1.4.7.


Revisions:
----------
538
539
540
541
542


Modified Paths:
---------------
mail/src/test/java/com/sun/mail/imap/IMAPIdleStateTest.java
mail/src/main/java/com/sun/mail/imap/protocol/INTERNALDATE.java
doc/release/CHANGES.txt
mail/src/main/java/javax/mail/internet/InternetAddress.java
mail/src/test/java/javax/mail/internet/InternetAddressTest.java
mail/src/test/resources/javax/mail/internet/addrlist
mail/src/main/java/javax/mail/Service.java
.hgtags
client/pom.xml
demo/pom.xml
dsn/pom.xml
gimap/pom.xml
imap/pom.xml
javadoc/pom.xml
logging/pom.xml
mail/pom.xml
mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
mailapi/pom.xml
mailapijar/pom.xml
mbox/dist/pom.xml
mbox/native/pom.xml
mbox/pom.xml
oldmail/pom.xml
outlook/pom.xml
parent-distrib/pom.xml
pom.xml
pop3/pom.xml
servlet/pom.xml
smtp/pom.xml
taglib/pom.xml
webapp/pom.xml


Diffs:
------
diff -r 0b49cb3cd71c -r 83331cafc41d mail/src/test/java/com/sun/mail/imap/IMAPIdleStateTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPIdleStateTest.java Fri Mar 08 15:37:30 2013 -0800
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPIdleStateTest.java Fri Mar 15 15:47:53 2013 -0700
@@ -75,7 +75,7 @@
             properties.setProperty("mail.imap.host", "localhost");
             properties.setProperty("mail.imap.port", "26422");
             final Session session = Session.getInstance(properties);
- session.setDebug(true);
+ //session.setDebug(true);
 
             final IMAPStore store = (IMAPStore)session.getStore("imap");
             try {


diff -r 83331cafc41d -r 5ddef14b4550 mail/src/main/java/com/sun/mail/imap/protocol/INTERNALDATE.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/INTERNALDATE.java Fri Mar 15 15:47:53 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/INTERNALDATE.java Fri Mar 15 16:03:41 2013 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -122,15 +122,9 @@
         }
 
         // compute timezone offset string
- // XXX - Yes, I know this is deprecated
- int rawOffsetInMins = -d.getTimezoneOffset();
- /*
- * XXX - in JavaMail 1.4 / J2SE 1.4, possibly replace above with:
- *
         TimeZone tz = TimeZone.getDefault();
- int offset = tz.getOffset(d); // get offset from GMT
+ int offset = tz.getOffset(d.getTime()); // get offset from GMT
         int rawOffsetInMins = offset / 60 / 1000; // offset from GMT in mins
- */
         if (rawOffsetInMins < 0) {
             sb.append('-');
             rawOffsetInMins = (-rawOffsetInMins);


diff -r 5ddef14b4550 -r 37f4e09c9ce8 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Fri Mar 15 16:03:41 2013 -0700
+++ b/doc/release/CHANGES.txt Fri Mar 15 16:15:01 2013 -0700
@@ -37,6 +37,7 @@
 K 5819 enable RFC 2231 support by default
 K 5829 NullPointerException when accessing the content of a message attachment
 K 5830 IMAPProtocol.sasllogin uses old constructor for IMAPSaslAuthenticator
+K 5847 Exception when parsing bad address with unclosed quote in mail header
 
 
                   CHANGES IN THE 1.4.6 RELEASE

diff -r 5ddef14b4550 -r 37f4e09c9ce8 mail/src/main/java/javax/mail/internet/InternetAddress.java
--- a/mail/src/main/java/javax/mail/internet/InternetAddress.java Fri Mar 15 16:03:41 2013 -0700
+++ b/mail/src/main/java/javax/mail/internet/InternetAddress.java Fri Mar 15 16:15:01 2013 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -367,7 +367,7 @@
     }
 
     private static String unquote(String s) {
- if (s.startsWith("\"") && s.endsWith("\"")) {
+ if (s.startsWith("\"") && s.endsWith("\"") && s.length() > 1) {
             s = s.substring(1, s.length() - 1);
             // check for any escaped characters
             if (s.indexOf('\\') >= 0) {

diff -r 5ddef14b4550 -r 37f4e09c9ce8 mail/src/test/java/javax/mail/internet/InternetAddressTest.java
--- a/mail/src/test/java/javax/mail/internet/InternetAddressTest.java Fri Mar 15 16:03:41 2013 -0700
+++ b/mail/src/test/java/javax/mail/internet/InternetAddressTest.java Fri Mar 15 16:15:01 2013 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -185,7 +185,7 @@
                         int nexpect = Integer.parseInt(s.substring(8));
                         expect = new String[nexpect];
                         for (i = 0; i < nexpect; i++)
- expect[i] = in.readLine().trim();
+ expect[i] = readLine(in).trim();
                     } catch (NumberFormatException e) {
                         try {
                             if (s.substring(8, 17).equals("Exception")) {
@@ -228,6 +228,34 @@
         return header.substring(header.indexOf(':') + 1).trim();
     }
 
+ /**
+ * Read an "expected" line, handling continuations
+ * (backslash at end of line). If line ends with
+ * two backslashes, it's not a continuation, just a
+ * line that ends with a single backslash.
+ */
+ private static String readLine(BufferedReader in) throws IOException {
+ String line = in.readLine();
+ if (!line.endsWith("\\"))
+ return line;
+ if (line.endsWith("\\\\"))
+ return line.substring(0, line.length() - 1);
+ StringBuilder sb = new StringBuilder(line);
+ sb.setCharAt(sb.length() - 1, '\n');
+ for (;;) {
+ line = in.readLine();
+ sb.append(line);
+ if (!line.endsWith("\\"))
+ break;
+ if (line.endsWith("\\\\")) {
+ sb.setLength(sb.length() - 1);
+ break;
+ }
+ sb.setCharAt(sb.length() - 1, '\n');
+ }
+ return sb.toString();
+ }
+
     @Test
     public void testAddress() {
         test(headerName, headerValue, expected, doStrict, doParseHeader);
@@ -265,7 +293,7 @@
             }
             for (int i = 0; i < al.length; i++) {
                 if (gen_test_input)
- pr("\t" + al[i].getAddress());
+ pr("\t" + al[i].getAddress()); // XXX - escape newlines
                 else {
                     pr("\t[" + (i+1) + "] " + al[i].getAddress() +
                         "\t\tPersonal: " + n(al[i].getPersonal()));

diff -r 5ddef14b4550 -r 37f4e09c9ce8 mail/src/test/resources/javax/mail/internet/addrlist
--- a/mail/src/test/resources/javax/mail/internet/addrlist Fri Mar 15 16:03:41 2013 -0700
+++ b/mail/src/test/resources/javax/mail/internet/addrlist Fri Mar 15 16:15:01 2013 -0700
@@ -2,7 +2,7 @@
 
     DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
- Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
 
     The contents of this file are subject to the terms of either the GNU
     General Public License Version 2 only ("GPL") or the Common Development
@@ -487,6 +487,8 @@
         iconv_at_cachaca, questions_at_cachaca
 Expect: Exception javax.mail.internet.AddressException: Nested group in string ``Re:@cachaca, Subject:@cachaca, and_at_cachaca, getmclist_at_cachaca, glenn_at_ivrel,
         iconv_at_cachaca, questions_at_cachaca'' at position 20
+To: " <string_at_string.ru>
+Expect: Exception javax.mail.internet.AddressException: Missing '"' in string ``" <string_at_string.ru> '' at position 22
 Comment:
         Now parse all the above bad addresses as if they were in a header,
         expecting no failures.
@@ -680,7 +682,7 @@
         Navy.Beans_at_4email-03
 To: \(^^/_at_nwkea-mail-2.sun.com
 Expect: 1
- \
+ \\
 Cc: <tom.ross_at_sun.com>, Cc: <javamail_at_sun.com>, Cc: <javahi_at_sun.com>,
    Cc: <javadoc-tool_at_sun.com>, Cc: <javacard-feedback_at_sun.com>
 Expect: 5
@@ -726,6 +728,43 @@
 To: "ULTIMA. OPORTUNIDAD*
 Expect: 1
         "ULTIMA. OPORTUNIDAD*
+Cc: 55:55_at_07, 57:18_at_07, 36:39_at_10, 36:42_at_10, streetwalker!1987, streetwalker!5,
+ streetwalker!87, <8710051455.AA08484_at_oak.sunecd.com>, <oak!kinnear>,
+ streetwalker!AA00159;, streetwalker!AA08484;, streetwalker!AA16178;,
+ streetwalker!Date:, streetwalker!EDT, streetwalker!Ecd.Sun.COM,
+ streetwalker!From, streetwalker!From:, streetwalker!Message-Id:,
+ streetwalker!Mon, streetwalker!Oct, streetwalker!PDT, streetwalker!RO,
+ streetwalker!Received:, streetwalker!Return-Path:,
+ streetwalker!Status:, streetwalker!To:, streetwalker!by,
+ streetwalker!from, streetwalker!id, streetwalker!oak.sunecd.com,
+ streetwalker!root, streetwalker!rr, streetwalker!streetwalker.sun.com
+Expect: 24
+ 55:55_at_07, 57:18_at_07, 36:39_at_10, 36:42_at_10, streetwalker!1987, streetwalker!5,\
+ streetwalker!87, <8710051455.AA08484_at_oak.sunecd.com>, <oak!kinnear>,\
+ streetwalker!AA00159;
+ streetwalker!AA08484
+ streetwalker!AA16178
+ streetwalker!Date:
+ streetwalker!EDT
+ streetwalker!Ecd.Sun.COM
+ streetwalker!From
+ streetwalker!From:
+ streetwalker!Message-Id:
+ streetwalker!Mon
+ streetwalker!Oct
+ streetwalker!PDT
+ streetwalker!RO
+ streetwalker!Received:
+ streetwalker!Return-Path:
+ streetwalker!Status:
+ streetwalker!To:
+ streetwalker!by
+ streetwalker!from
+ streetwalker!id
+ streetwalker!oak.sunecd.com
+ streetwalker!root
+ streetwalker!rr
+ streetwalker!streetwalker.sun.com
 To: Re:@cachaca, Subject:@cachaca, and_at_cachaca, getmclist_at_cachaca, glenn_at_ivrel,
         iconv_at_cachaca, questions_at_cachaca
 Expect: 7
@@ -736,4 +775,7 @@
         glenn_at_ivrel
         iconv_at_cachaca
         questions_at_cachaca
+To: " <string_at_string.ru>
+Expect: 1
+ string_at_string.ru
 Header: false


diff -r 37f4e09c9ce8 -r cee0d5ec7563 mail/src/main/java/javax/mail/Service.java
--- a/mail/src/main/java/javax/mail/Service.java Fri Mar 15 16:15:01 2013 -0700
+++ b/mail/src/main/java/javax/mail/Service.java Mon Mar 18 20:14:53 2013 -0700
@@ -95,8 +95,58 @@
      */
     protected Service(Session session, URLName urlname) {
         this.session = session;
+ debug = session.getDebug();
         url = urlname;
- debug = session.getDebug();
+
+ /*
+ * Initialize the URLName with default values.
+ * The URLName will be updated when connect is called.
+ */
+ String protocol = null;
+ String host = null;
+ int port = -1;
+ String user = null;
+ String password = null;
+ String file = null;
+
+ // get whatever information we can from the URL
+ // XXX - url should always be non-null here, Session
+ // passes it into the constructor
+ if (url != null) {
+ protocol = url.getProtocol();
+ host = url.getHost();
+ port = url.getPort();
+ user = url.getUsername();
+ password = url.getPassword();
+ file = url.getFile();
+ }
+
+ // try to get protocol-specific default properties
+ if (protocol != null) {
+ if (host == null)
+ host = session.getProperty("mail." + protocol + ".host");
+ if (user == null)
+ user = session.getProperty("mail." + protocol + ".user");
+ }
+
+ // try to get mail-wide default properties
+ if (host == null)
+ host = session.getProperty("mail.host");
+
+ if (user == null)
+ user = session.getProperty("mail.user");
+
+ // try using the system username
+ if (user == null) {
+ try {
+ user = System.getProperty("user.name");
+ } catch (SecurityException sex) {
+ // XXX - it's not worth creating a MailLogger just for this
+ //logger.log(Level.CONFIG, "Can't get user.name property", sex);
+ }
+ }
+
+ url = new URLName(protocol, host, port, file, user, password);
     }
 
     /**
@@ -266,8 +316,8 @@
             try {
                 user = System.getProperty("user.name");
             } catch (SecurityException sex) {
- if (debug)
- sex.printStackTrace(session.getDebugOut());
+ // XXX - it's not worth creating a MailLogger just for this
+ //logger.log(Level.CONFIG, "Can't get user.name property", sex);
             }
         }
 


diff -r cee0d5ec7563 -r 54627929ab4b .hgtags
--- a/.hgtags Mon Mar 18 20:14:53 2013 -0700
+++ b/.hgtags Mon Mar 18 20:17:54 2013 -0700
@@ -13,3 +13,4 @@
 b9c00b0cf3cf560077cd3c393c597e4ed9f1bf14 JAVAMAIL-1_4_6
 b9c00b0cf3cf560077cd3c393c597e4ed9f1bf14 JAVAMAIL-1_4_6
 3dba8c78634fcb1ffd9a32e840bcfab91a83a551 JAVAMAIL-1_4_6
+ba4e734fdfa9916c0e8867b8ea8b4218e276be0e JAVAMAIL-1_4_7

diff -r cee0d5ec7563 -r 54627929ab4b doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Mon Mar 18 20:14:53 2013 -0700
+++ b/doc/release/CHANGES.txt Mon Mar 18 20:17:54 2013 -0700
@@ -40,6 +40,14 @@
 K 5847 Exception when parsing bad address with unclosed quote in mail header
 
 
+ CHANGES IN THE 1.4.7 RELEASE
+ ----------------------------
+The following bugs have been fixed in the 1.4.7 release.
+
+K 5829 NullPointerException when accessing the content of a message attachment
+K 5830 IMAPProtocol.sasllogin uses old constructor for IMAPSaslAuthenticator
+
+
                   CHANGES IN THE 1.4.6 RELEASE
                   ----------------------------
 The following bugs have been fixed in the 1.4.6 release.