mirror of
https://github.com/moparisthebest/davmail
synced 2025-02-28 09:21:49 -05:00
IMAP: Detect fetch of a missing (probably deleted) message to avoid infinite loop with Thunderbird
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@565 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
023736018c
commit
dc82440cc0
@ -36,7 +36,8 @@ public class ImapConnection extends AbstractConnection {
|
||||
super(ImapConnection.class.getSimpleName(), clientSocket, null);
|
||||
}
|
||||
|
||||
@Override public void run() {
|
||||
@Override
|
||||
public void run() {
|
||||
String line;
|
||||
String commandId = null;
|
||||
IMAPTokenizer tokens;
|
||||
@ -192,16 +193,26 @@ public class ImapConnection extends AbstractConnection {
|
||||
sendClient(commandId + " NO no folder selected");
|
||||
} else {
|
||||
currentFolder = session.refreshFolder(currentFolder);
|
||||
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(tokens.nextToken());
|
||||
String parameters = null;
|
||||
if (tokens.hasMoreTokens()) {
|
||||
parameters = tokens.nextToken();
|
||||
String ranges = tokens.nextToken();
|
||||
if (ranges == null) {
|
||||
sendClient(commandId + " BAD missing range parameter");
|
||||
} else {
|
||||
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(ranges);
|
||||
String parameters = null;
|
||||
if (tokens.hasMoreTokens()) {
|
||||
parameters = tokens.nextToken();
|
||||
}
|
||||
if (!uidRangeIterator.hasNext() && ranges.indexOf(':') < 0) {
|
||||
// message not found in current list, maybe deleted in another thread
|
||||
sendClient(commandId + " NO No message found");
|
||||
} else {
|
||||
while (uidRangeIterator.hasNext()) {
|
||||
ExchangeSession.Message message = uidRangeIterator.next();
|
||||
handleFetch(message, uidRangeIterator.currentIndex, parameters);
|
||||
}
|
||||
sendClient(commandId + " OK UID FETCH completed");
|
||||
}
|
||||
}
|
||||
while (uidRangeIterator.hasNext()) {
|
||||
ExchangeSession.Message message = uidRangeIterator.next();
|
||||
handleFetch(message, uidRangeIterator.currentIndex, parameters);
|
||||
}
|
||||
sendClient(commandId + " OK UID FETCH completed");
|
||||
}
|
||||
|
||||
} else if ("search".equalsIgnoreCase(subcommand)) {
|
||||
@ -441,7 +452,7 @@ public class ImapConnection extends AbstractConnection {
|
||||
} catch (Exception e) {
|
||||
DavGatewayTray.error(e);
|
||||
try {
|
||||
String message = (e.getMessage()==null)?e.toString():e.getMessage();
|
||||
String message = (e.getMessage() == null) ? e.toString() : e.getMessage();
|
||||
if (commandId != null) {
|
||||
sendClient(commandId + " BAD unable to handle request: " + message);
|
||||
} else {
|
||||
@ -907,7 +918,7 @@ public class ImapConnection extends AbstractConnection {
|
||||
protected final int startIndex;
|
||||
|
||||
private PartOutputStream(OutputStream os, boolean writeHeaders, boolean writeBody,
|
||||
int startIndex) {
|
||||
int startIndex) {
|
||||
super(os);
|
||||
this.writeHeaders = writeHeaders;
|
||||
this.writeBody = writeBody;
|
||||
|
Loading…
x
Reference in New Issue
Block a user