1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 19:52:17 -05:00

Fixes Issue 448

Fixes Issue 651
This commit is contained in:
Daniel Applebaum 2009-10-28 12:45:22 +00:00
parent 25e36da75d
commit 8951363442

View File

@ -22,6 +22,9 @@ import com.android.email.mail.MessagingException;
public class ImapResponseParser { public class ImapResponseParser {
SimpleDateFormat mDateTimeFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z", Locale.US); SimpleDateFormat mDateTimeFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z", Locale.US);
SimpleDateFormat badDateTimeFormat = new SimpleDateFormat("dd MMM yyyy HH:mm:ss Z", Locale.US);
PeekableInputStream mIn; PeekableInputStream mIn;
InputStream mActiveLiteral; InputStream mActiveLiteral;
@ -208,7 +211,7 @@ public class ImapResponseParser {
// contain // contain
// * and some falgs contain * // * and some falgs contain *
// ch == '%' || ch == '*' || // ch == '%' || ch == '*' ||
ch == '%' || // ch == '%' ||
// TODO probably should not allow \ and should recognize // TODO probably should not allow \ and should recognize
// it as a flag instead // it as a flag instead
// ch == '"' || ch == '\' || // ch == '"' || ch == '\' ||
@ -301,7 +304,7 @@ public class ImapResponseParser {
public Date getDate(int index) throws MessagingException { public Date getDate(int index) throws MessagingException {
try { try {
return mDateTimeFormat.parse(getString(index)); return parseDate(getString(index));
} catch (ParseException pe) { } catch (ParseException pe) {
throw new MessagingException("Unable to parse IMAP datetime", pe); throw new MessagingException("Unable to parse IMAP datetime", pe);
} }
@ -338,11 +341,31 @@ public class ImapResponseParser {
if (value == null) { if (value == null) {
return null; return null;
} }
return mDateTimeFormat.parse(value); return parseDate(value);
} catch (ParseException pe) { } catch (ParseException pe) {
throw new MessagingException("Unable to parse IMAP datetime", pe); throw new MessagingException("Unable to parse IMAP datetime", pe);
} }
} }
private Date parseDate(String value) throws ParseException
{
try
{
synchronized(mDateTimeFormat)
{
return mDateTimeFormat.parse(value);
}
}
catch (Exception e)
{
synchronized(badDateTimeFormat)
{
return badDateTimeFormat.parse(value);
}
}
}
} }
/** /**