This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git


The following commit(s) were added to refs/heads/master by this push:
     new 33d23d6  NET-673 IMAPClient.APPEND does not always calculate the 
correct length
33d23d6 is described below

commit 33d23d6b6a3201cc3ffe2eb16a0e8a1a4a4b4c8a
Author: Sebb <[email protected]>
AuthorDate: Tue Sep 24 22:57:52 2019 +0100

    NET-673 IMAPClient.APPEND does not always calculate the correct length
---
 src/changes/changes.xml                                   | 3 +++
 src/main/java/org/apache/commons/net/imap/IMAPClient.java | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d7b5670..643e18d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -74,6 +74,9 @@ This is mainly a bug-fix release. See further details below.
  The examples are not part of the public API, so this does not affect 
compatibility.
 
 ">
+            <action issue="NET-673" type="fix" dev="sebb">
+            IMAPClient.APPEND does not always calculate the correct length
+            </action>
             <action issue="NET-646" type="add" dev="sebb">
             ALLO FTP Command for files >2GB
             </action>
diff --git a/src/main/java/org/apache/commons/net/imap/IMAPClient.java 
b/src/main/java/org/apache/commons/net/imap/IMAPClient.java
index fd243a3..51e306f 100644
--- a/src/main/java/org/apache/commons/net/imap/IMAPClient.java
+++ b/src/main/java/org/apache/commons/net/imap/IMAPClient.java
@@ -266,12 +266,12 @@ public class IMAPClient extends IMAP
             }
         }
         args.append(" ");
-        // String literal (probably not used much - it at all)
+        // String literal (probably not used much - if at all)
         if (message.startsWith(DQUOTE_S) && message.endsWith(DQUOTE_S)) {
             args.append(message);
             return doCommand (IMAPCommand.APPEND, args.toString());
         }
-        args.append('{').append(message.length()).append('}'); // length of 
message
+        
args.append('{').append(message.getBytes(IMAP.__DEFAULT_ENCODING).length).append('}');
 // length of message
         final int status = sendCommand(IMAPCommand.APPEND, args.toString());
         return IMAPReply.isContinuation(status) // expecting continuation 
response
             && IMAPReply.isSuccess(sendData(message)); // if so, send the data

Reply via email to