IMAP: Fix message write, double dot only for POP, not IMAP

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@988 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-04-02 15:35:37 +00:00
parent 0187caaa3f
commit f0a7f1ae76
2 changed files with 9 additions and 8 deletions

View File

@ -1605,18 +1605,19 @@ public class ExchangeSession {
* Write MIME message to os
*
* @param os output stream
* @param doubleDot replace '.' lines with '..' (POP protocol)
* @throws IOException on error
*/
public void write(OutputStream os) throws IOException {
public void write(OutputStream os, boolean doubleDot) throws IOException {
try {
write(os, messageUrl);
write(os, messageUrl, doubleDot);
} catch (HttpNotFoundException e) {
LOGGER.debug("Message not found at: " + messageUrl + ", retrying with permanenturl");
write(os, permanentUrl);
write(os, permanentUrl, doubleDot);
}
}
protected void write(OutputStream os, String url) throws IOException {
protected void write(OutputStream os, String url, boolean doubleDot) throws IOException {
GetMethod method = new GetMethod(URIUtil.encodePath(url));
method.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
method.setRequestHeader("Translate", "f");
@ -1628,7 +1629,7 @@ public class ExchangeSession {
OutputStreamWriter isoWriter = new OutputStreamWriter(os);
String line;
while ((line = reader.readLine()) != null) {
if (".".equals(line)) {
if (doubleDot && ".".equals(line)) {
line = "..";
// patch text/calendar to include utf-8 encoding
} else if ("Content-Type: text/calendar;".equals(line)) {
@ -1677,7 +1678,7 @@ public class ExchangeSession {
public MimeMessage getMimeMessage() throws IOException, MessagingException {
if (mimeMessage == null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
write(baos);
write(baos, false);
mimeMessage = new MimeMessage(null, new ByteArrayInputStream(baos.toByteArray()));
}
return mimeMessage;

View File

@ -195,7 +195,7 @@ public class PopConnection extends AbstractConnection {
try {
int messageNumber = Integer.valueOf(tokens.nextToken()) - 1;
sendOK("");
messages.get(messageNumber).write(os);
messages.get(messageNumber).write(os, true);
sendClient("");
sendClient(".");
} catch (SocketException e) {
@ -232,7 +232,7 @@ public class PopConnection extends AbstractConnection {
int lines = Integer.valueOf(tokens.nextToken());
ExchangeSession.Message m = messages.get(message - 1);
sendOK("");
m.write(new TopOutputStream(os, lines));
m.write(new TopOutputStream(os, lines), true);
sendClient("");
sendClient(".");
} catch (NumberFormatException e) {