Project: javamail
Repository: mercurial
Revision: 918
Author: shannon
Date: 2017-04-14 21:07:34 UTC
Link:
Log Message:
------------
Version back to 1.6.0-SNAPSHOT.
support UIDPLUS UIDNOTSTICKY response code - bug 19563
UTF-8 content wasn't being handled properly in IMAP responses.
Revisions:
----------
916
917
918
Modified Paths:
---------------
android/activation/pom.xml
android/mail/pom.xml
android/pom.xml
client/pom.xml
demo/pom.xml
dsn/pom.xml
gimap/pom.xml
imap/pom.xml
javadoc/pom.xml
logging/pom.xml
mail/pom.xml
mailapi/pom.xml
mailapijar/pom.xml
mailhandler/pom.xml
mbox/pom.xml
outlook/pom.xml
parent-distrib/pom.xml
pom.xml
pop3/pom.xml
publish/pom.xml
servlet/pom.xml
smtp/pom.xml
taglib/pom.xml
update_version
webapp/pom.xml
doc/release/CHANGES.txt
mail/src/main/java/com/sun/mail/imap/IMAPFolder.java
mail/src/main/java/com/sun/mail/imap/protocol/MailboxInfo.java
mail/src/test/java/com/sun/mail/imap/IMAPFolderTest.java
mail/src/main/java/com/sun/mail/iap/Response.java
mail/src/test/java/com/sun/mail/imap/IMAPMessageTest.java
Diffs:
------
diff -r 990d55e90e6c -r 845274aeede8 android/activation/pom.xml
--- a/android/activation/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/android/activation/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>android</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 android/mail/pom.xml
--- a/android/mail/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/android/mail/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -52,7 +52,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>android</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 android/pom.xml
--- a/android/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/android/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 client/pom.xml
--- a/client/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/client/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 demo/pom.xml
--- a/demo/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/demo/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 dsn/pom.xml
--- a/dsn/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/dsn/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 gimap/pom.xml
--- a/gimap/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/gimap/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 imap/pom.xml
--- a/imap/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/imap/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>parent-distrib</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
<relativePath>../parent-distrib/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff -r 990d55e90e6c -r 845274aeede8 javadoc/pom.xml
--- a/javadoc/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/javadoc/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,13 +48,13 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
<artifactId>javadoc</artifactId>
<packaging>pom</packaging>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
<name>JavaMail API javadocs</name>
<description>${project.name}</description>
diff -r 990d55e90e6c -r 845274aeede8 logging/pom.xml
--- a/logging/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/logging/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 mail/pom.xml
--- a/mail/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/mail/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 mailapi/pom.xml
--- a/mailapi/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/mailapi/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -56,7 +56,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 mailapijar/pom.xml
--- a/mailapijar/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/mailapijar/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -55,7 +55,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>javax.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 mailhandler/pom.xml
--- a/mailhandler/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/mailhandler/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>parent-distrib</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
<relativePath>../parent-distrib/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff -r 990d55e90e6c -r 845274aeede8 mbox/pom.xml
--- a/mbox/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/mbox/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 outlook/pom.xml
--- a/outlook/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/outlook/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 parent-distrib/pom.xml
--- a/parent-distrib/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/parent-distrib/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 pom.xml
--- a/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -54,7 +54,7 @@
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
<packaging>pom</packaging>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
<name>JavaMail API distribution</name>
<description>${project.name}</description>
<url>
http://javamail.java.net</url>
diff -r 990d55e90e6c -r 845274aeede8 pop3/pom.xml
--- a/pop3/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/pop3/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>parent-distrib</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
<relativePath>../parent-distrib/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff -r 990d55e90e6c -r 845274aeede8 publish/pom.xml
--- a/publish/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/publish/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,13 +48,13 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
<artifactId>publish</artifactId>
<packaging>pom</packaging>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
<name>JavaMail API publish project</name>
<build>
@@ -89,7 +89,7 @@
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</dependency>
<!--
<dependency>
diff -r 990d55e90e6c -r 845274aeede8 servlet/pom.xml
--- a/servlet/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/servlet/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 smtp/pom.xml
--- a/smtp/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/smtp/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>parent-distrib</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
<relativePath>../parent-distrib/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff -r 990d55e90e6c -r 845274aeede8 taglib/pom.xml
--- a/taglib/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/taglib/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 990d55e90e6c -r 845274aeede8 update_version
--- a/update_version Mon Mar 20 17:05:14 2017 -0700
+++ b/update_version Mon Apr 10 17:10:07 2017 -0700
@@ -2,7 +2,7 @@
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
-# Copyright (c) 2010-2012 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010-2017 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
@@ -48,6 +48,8 @@
#
new=$1
# find the second version string in pom.xml, which is the old version
+# this is almost the same as "mvn versions:set -DnewVersion=$1"
+# except that misses mbox/native/pom.xml and oldmail/pom.xml
old=`grep '<version>.*</version>' pom.xml | sed -n 2p | \
sed -e 's:.*<version>\(.*\)</version>.*:\1:'`
for file in `find . -name 'pom.xml' `
diff -r 990d55e90e6c -r 845274aeede8 webapp/pom.xml
--- a/webapp/pom.xml Mon Mar 20 17:05:14 2017 -0700
+++ b/webapp/pom.xml Mon Apr 10 17:10:07 2017 -0700
@@ -48,7 +48,7 @@
<parent>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
- <version>1.6.0-rc1</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.mail</groupId>
diff -r 845274aeede8 -r fee89795eb19 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Mon Apr 10 17:10:07 2017 -0700
+++ b/doc/release/CHANGES.txt Mon Apr 10 17:13:22 2017 -0700
@@ -52,6 +52,7 @@
K 8846 MimeUtility.unfold squashes multiple spaces
K 9169 JavaMail PLAIN authentication should implement RFC 4616
K 9418 Support connecting through web proxy servers
+K 19563 support UIDPLUS UIDNOTSTICKY response code
CHANGES IN THE 1.5.6 RELEASE
diff -r 845274aeede8 -r fee89795eb19 mail/src/main/java/com/sun/mail/imap/IMAPFolder.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Mon Apr 10 17:10:07 2017 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Mon Apr 10 17:13:22 2017 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 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
@@ -276,6 +276,7 @@
// the server
private long uidvalidity = -1; // UIDValidity
private long uidnext = -1; // UIDNext
+ private boolean uidNotSticky = false; // RFC 4315
private volatile long highestmodseq = -1; // RFC 4551 - CONDSTORE
private boolean doExpungeNotification = true; // used in expunge handler
@@ -1108,6 +1109,7 @@
recent = mi.recent;
uidvalidity = mi.uidvalidity;
uidnext = mi.uidnext;
+ uidNotSticky = mi.uidNotSticky;
highestmodseq = mi.highestmodseq;
// Create the message cache of appropriate size
@@ -2768,6 +2770,24 @@
}
/**
+ * Servers that support the UIDPLUS extension
+ * (<A HREF="
http://www.ietf.org/rfc/rfc4315.txt">RFC 4315</A>)
+ * may indicate that this folder does not support persistent UIDs;
+ * that is, UIDVALIDITY will be different each time the folder is
+ * opened. Only valid when the folder is open.
+ *
+ * @return true if UIDs are not sticky
+ * @exception MessagingException for failures
+ * @exception IllegalStateException if the folder isn't open
+ * @see "RFC 4315"
+ * @since JavaMail 1.6.0
+ */
+ public synchronized boolean getUIDNotSticky() throws MessagingException {
+ checkOpened();
+ return uidNotSticky;
+ }
+
+ /**
* Get or create Message objects for the UIDs.
*/
private Message[] createMessagesForUIDs(long[] uids) {
diff -r 845274aeede8 -r fee89795eb19 mail/src/main/java/com/sun/mail/imap/protocol/MailboxInfo.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/MailboxInfo.java Mon Apr 10 17:10:07 2017 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/MailboxInfo.java Mon Apr 10 17:13:22 2017 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 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
@@ -69,6 +69,8 @@
public long uidvalidity = -1;
/** The next UID value to be assigned. */
public long uidnext = -1;
+ /** UIDs are not sticky. */
+ public boolean uidNotSticky = false; // RFC 4315
/** The highest MODSEQ value. */
public long highestmodseq = -1; // RFC 4551 - CONDSTORE
/** Folder.READ_WRITE or Folder.READ_ONLY, set by IMAPProtocol. */
@@ -144,6 +146,29 @@
r[i] = null; // remove this response
else
ir.reset(); // so ALERT can be read
+ } else if (ir.isUnTagged() && ir.isNO()) {
+ /*
+ * should be one of:
+ * * NO [UIDNOTSTICKY]
+ */
+ ir.skipSpaces();
+
+ if (ir.readByte() != '[') { // huh ???
+ ir.reset();
+ continue;
+ }
+
+ boolean handled = true;
+ String s = ir.readAtom();
+ if (s.equalsIgnoreCase("UIDNOTSTICKY"))
+ uidNotSticky = true;
+ else
+ handled = false; // possibly an ALERT
+
+ if (handled)
+ r[i] = null; // remove this response
+ else
+ ir.reset(); // so ALERT can be read
}
}
diff -r 845274aeede8 -r fee89795eb19 mail/src/test/java/com/sun/mail/imap/IMAPFolderTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPFolderTest.java Mon Apr 10 17:10:07 2017 -0700
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPFolderTest.java Mon Apr 10 17:13:22 2017 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2009-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2017 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
@@ -403,6 +403,56 @@
});
}
+ /**
+ * Test that UIDNOTSTICKY is false in the formal case.
+ */
+ @Test
+ public void testUidNotStickyFalse() {
+ testWithHandler(
+ new IMAPTest() {
+ @Override
+ public void test(Store store, IMAPHandler handler)
+ throws MessagingException, IOException {
+ Folder test = store.getFolder("test");
+ try {
+ test.open(Folder.READ_WRITE);
+ assertFalse(((IMAPFolder)test).getUIDNotSticky());
+ } finally {
+ test.close();
+ }
+ }
+ },
+ new IMAPHandler());
+ }
+
+ /**
+ * Test that UIDNOTSTICKY is true when the untagged response is included.
+ */
+ @Test
+ public void testUidNotStickyTrue() {
+ testWithHandler(
+ new IMAPTest() {
+ @Override
+ public void test(Store store, IMAPHandler handler)
+ throws MessagingException, IOException {
+ Folder test = store.getFolder("test");
+ try {
+ test.open(Folder.READ_WRITE);
+ assertTrue(((IMAPFolder)test).getUIDNotSticky());
+ } finally {
+ test.close();
+ }
+ }
+ },
+ new IMAPHandler() {
+ @Override
+ public void select(String line) throws IOException {
+ untagged("NO [UIDNOTSTICKY]");
+ super.select(line);
+ }
+ });
+ }
+
private void testWithHandler(IMAPTest test, IMAPHandler handler) {
TestServer server = null;
try {
diff -r fee89795eb19 -r 2c37a4eb5532 mail/src/main/java/com/sun/mail/iap/Response.java
--- a/mail/src/main/java/com/sun/mail/iap/Response.java Mon Apr 10 17:13:22 2017 -0700
+++ b/mail/src/main/java/com/sun/mail/iap/Response.java Fri Apr 14 14:07:34 2017 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 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
@@ -63,8 +63,7 @@
protected String tag = null;
/** @since JavaMail 1.5.4 */
protected Exception ex;
-
- private boolean utf8;
+ protected boolean utf8;
private static final int increment = 100;
@@ -144,10 +143,13 @@
*/
public Response(Response r) {
index = r.index;
+ pindex = r.pindex;
size = r.size;
buffer = r.buffer;
type = r.type;
tag = r.tag;
+ ex = r.ex;
+ utf8 = r.utf8;
}
/**
diff -r fee89795eb19 -r 2c37a4eb5532 mail/src/test/java/com/sun/mail/imap/IMAPMessageTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPMessageTest.java Mon Apr 10 17:13:22 2017 -0700
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPMessageTest.java Fri Apr 14 14:07:34 2017 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2009-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2017 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
@@ -41,6 +41,7 @@
package com.sun.mail.imap;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Set;
@@ -53,6 +54,7 @@
import javax.mail.Multipart;
import javax.mail.BodyPart;
import javax.mail.MessagingException;
+import javax.mail.internet.MimeUtility;
import com.sun.mail.test.TestServer;
@@ -74,13 +76,21 @@
public Timeout deadlockTimeout = Timeout.seconds(20);
private static final String RDATE = "23-Jun-2004 06:26:26 -0700";
- private static final String ENVELOPE =
- "(\"Wed, 23 Jun 2004 18:56:42 +0530\" \"test\" " +
+ private static final String ENV_DATE =
+ "\"Wed, 23 Jun 2004 18:56:42 +0530\"";
+ private static final String ENV_SUBJECT = "\"test\"";
+ private static final String ENV_UTF8_ENCODED_SUBJECT =
+ "=?UTF-8?B?VVRGOCB0ZXN0OiDgsqzgsr4g4LKH4LKy4LON4LKy4LK/IOCyuOCygg==?= " +
+ "=?UTF-8?B?4LKt4LK14LK/4LK44LOBIOCyh+CyguCypuCzhuCyqA==?= " +
+ "=?UTF-8?B?4LON4LKoIOCyueCzg+CypuCyr+CypuCysuCyvyA=?=";
+ private static final String ENV_ADDRS =
"((\"JavaMail\" NIL \"testuser\" \"example.com\")) " +
"((\"JavaMail\" NIL \"testuser\" \"example.com\")) " +
"((\"JavaMail\" NIL \"testuser\" \"example.com\")) " +
"((NIL NIL \"testuser\" \"example.com\")) NIL NIL NIL " +
- "\"<40D98512.9040803_at_example.com>\")";
+ "\"<40D98512.9040803_at_example.com>\"";
+ private static final String ENVELOPE =
+ "(" + ENV_DATE + " " + ENV_SUBJECT + " " + ENV_ADDRS + ")";
public static abstract class IMAPTest {
public void init(Properties props) { };
@@ -208,6 +218,71 @@
});
}
+ /**
+ * Test that a UTF-8 encoded Subject is decoded properly.
+ */
+ @Test
+ public void testUtf8SubjectEncoded() {
+ String s = null;
+ try {
+ s = MimeUtility.decodeText(ENV_UTF8_ENCODED_SUBJECT);
+ } catch (UnsupportedEncodingException ex) {
+ }
+ final String subject = s;
+
+ testWithHandler(
+ new IMAPTest() {
+ @Override
+ public void test(Folder folder, IMAPHandlerMessage handler)
+ throws MessagingException {
+ Message m = folder.getMessage(1);
+ assertEquals(subject, m.getSubject());
+ }
+ },
+ new IMAPHandlerMessage() {
+ {{
+ envelope = "(" + ENV_DATE + " \"" +
+ ENV_UTF8_ENCODED_SUBJECT + "\" " +
+ ENV_ADDRS + ")";
+ }}
+ });
+ }
+
+ /**
+ * Test that a UTF-8 Subject is decoded properly.
+ */
+ @Test
+ public void testUtf8Subject() {
+ String s = null;
+ try {
+ s = MimeUtility.decodeText(ENV_UTF8_ENCODED_SUBJECT);
+ } catch (UnsupportedEncodingException ex) {
+ }
+ final String subject = s;
+
+ testWithHandler(
+ new IMAPTest() {
+ @Override
+ public void test(Folder folder, IMAPHandlerMessage handler)
+ throws MessagingException {
+ Message m = folder.getMessage(1);
+ assertEquals(subject, m.getSubject());
+ }
+ },
+ new IMAPHandlerMessage() {
+ {{
+ envelope = "(" + ENV_DATE + " \"" + subject + "\" " +
+ ENV_ADDRS + ")";
+ capabilities += " ENABLE UTF8=ACCEPT";
+ }}
+
+ @Override
+ public void enable(String line) throws IOException {
+ ok();
+ }
+ });
+ }
+
private void testWithHandler(IMAPTest test, IMAPHandlerMessage handler) {
TestServer server = null;
try {