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:
parent
0187caaa3f
commit
f0a7f1ae76
|
@ -1605,18 +1605,19 @@ public class ExchangeSession {
|
||||||
* Write MIME message to os
|
* Write MIME message to os
|
||||||
*
|
*
|
||||||
* @param os output stream
|
* @param os output stream
|
||||||
|
* @param doubleDot replace '.' lines with '..' (POP protocol)
|
||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
public void write(OutputStream os) throws IOException {
|
public void write(OutputStream os, boolean doubleDot) throws IOException {
|
||||||
try {
|
try {
|
||||||
write(os, messageUrl);
|
write(os, messageUrl, doubleDot);
|
||||||
} catch (HttpNotFoundException e) {
|
} catch (HttpNotFoundException e) {
|
||||||
LOGGER.debug("Message not found at: " + messageUrl + ", retrying with permanenturl");
|
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));
|
GetMethod method = new GetMethod(URIUtil.encodePath(url));
|
||||||
method.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
|
method.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
|
||||||
method.setRequestHeader("Translate", "f");
|
method.setRequestHeader("Translate", "f");
|
||||||
|
@ -1628,7 +1629,7 @@ public class ExchangeSession {
|
||||||
OutputStreamWriter isoWriter = new OutputStreamWriter(os);
|
OutputStreamWriter isoWriter = new OutputStreamWriter(os);
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
if (".".equals(line)) {
|
if (doubleDot && ".".equals(line)) {
|
||||||
line = "..";
|
line = "..";
|
||||||
// patch text/calendar to include utf-8 encoding
|
// patch text/calendar to include utf-8 encoding
|
||||||
} else if ("Content-Type: text/calendar;".equals(line)) {
|
} else if ("Content-Type: text/calendar;".equals(line)) {
|
||||||
|
@ -1677,7 +1678,7 @@ public class ExchangeSession {
|
||||||
public MimeMessage getMimeMessage() throws IOException, MessagingException {
|
public MimeMessage getMimeMessage() throws IOException, MessagingException {
|
||||||
if (mimeMessage == null) {
|
if (mimeMessage == null) {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
write(baos);
|
write(baos, false);
|
||||||
mimeMessage = new MimeMessage(null, new ByteArrayInputStream(baos.toByteArray()));
|
mimeMessage = new MimeMessage(null, new ByteArrayInputStream(baos.toByteArray()));
|
||||||
}
|
}
|
||||||
return mimeMessage;
|
return mimeMessage;
|
||||||
|
|
|
@ -195,7 +195,7 @@ public class PopConnection extends AbstractConnection {
|
||||||
try {
|
try {
|
||||||
int messageNumber = Integer.valueOf(tokens.nextToken()) - 1;
|
int messageNumber = Integer.valueOf(tokens.nextToken()) - 1;
|
||||||
sendOK("");
|
sendOK("");
|
||||||
messages.get(messageNumber).write(os);
|
messages.get(messageNumber).write(os, true);
|
||||||
sendClient("");
|
sendClient("");
|
||||||
sendClient(".");
|
sendClient(".");
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
|
@ -232,7 +232,7 @@ public class PopConnection extends AbstractConnection {
|
||||||
int lines = Integer.valueOf(tokens.nextToken());
|
int lines = Integer.valueOf(tokens.nextToken());
|
||||||
ExchangeSession.Message m = messages.get(message - 1);
|
ExchangeSession.Message m = messages.get(message - 1);
|
||||||
sendOK("");
|
sendOK("");
|
||||||
m.write(new TopOutputStream(os, lines));
|
m.write(new TopOutputStream(os, lines), true);
|
||||||
sendClient("");
|
sendClient("");
|
||||||
sendClient(".");
|
sendClient(".");
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|
Loading…
Reference in New Issue