Skip to content

Commit 33d23d6

Browse files
committed
NET-673 IMAPClient.APPEND does not always calculate the correct length
1 parent 08321f0 commit 33d23d6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ This is mainly a bug-fix release. See further details below.
7474
The examples are not part of the public API, so this does not affect compatibility.
7575
7676
">
77+
<action issue="NET-673" type="fix" dev="sebb">
78+
IMAPClient.APPEND does not always calculate the correct length
79+
</action>
7780
<action issue="NET-646" type="add" dev="sebb">
7881
ALLO FTP Command for files >2GB
7982
</action>

src/main/java/org/apache/commons/net/imap/IMAPClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,12 @@ public boolean append(String mailboxName, String flags, String datetime, String
266266
}
267267
}
268268
args.append(" ");
269-
// String literal (probably not used much - it at all)
269+
// String literal (probably not used much - if at all)
270270
if (message.startsWith(DQUOTE_S) && message.endsWith(DQUOTE_S)) {
271271
args.append(message);
272272
return doCommand (IMAPCommand.APPEND, args.toString());
273273
}
274-
args.append('{').append(message.length()).append('}'); // length of message
274+
args.append('{').append(message.getBytes(IMAP.__DEFAULT_ENCODING).length).append('}'); // length of message
275275
final int status = sendCommand(IMAPCommand.APPEND, args.toString());
276276
return IMAPReply.isContinuation(status) // expecting continuation response
277277
&& IMAPReply.isSuccess(sendData(message)); // if so, send the data

0 commit comments

Comments
 (0)