Skip to content

Commit

Permalink
Fix do not return error on empty part returned from server, return ju…
Browse files Browse the repository at this point in the history
…st zero length (2)
  • Loading branch information
Sergei Epatov committed Mar 22, 2017
1 parent ff193e3 commit 8bceb3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/core/imap/MCIMAPSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ void IMAPSession::init()
mRamblerRuServer = false;
mHermesServer = false;
mQipServer = false;
mOutlookServer = false;
mLastFetchedSequenceNumber = 0;
mCurrentFolder = NULL;
pthread_mutex_init(&mIdleLock, NULL);
Expand Down Expand Up @@ -719,6 +720,7 @@ void IMAPSession::connect(ErrorCode * pError)
mRamblerRuServer = (mHostname->locationOfString(MCSTR(".rambler.ru")) != -1);
mHermesServer = (mWelcomeString->locationOfString(MCSTR("Hermes")) != -1);
mQipServer = (mWelcomeString->locationOfString(MCSTR("QIP IMAP server")) != -1);
mOutlookServer = (mHostname->locationOfString(MCSTR(".outlook.com")) != -1);
}

mState = STATE_CONNECTED;
Expand Down Expand Up @@ -1989,10 +1991,8 @@ void IMAPSession::expunge(String * folder, ErrorCode * pError)
* pError = ErrorNone;
}

static int
fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier,
struct mailimap_fetch_type * fetch_type,
char ** result, size_t * result_len)
int IMAPSession::fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier,
mailimap_fetch_type * fetch_type, char ** result, size_t * result_len)
{
int r;
struct mailimap_msg_att * msg_att;
Expand Down Expand Up @@ -2051,7 +2051,12 @@ fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier,
mailimap_fetch_list_free(fetch_result);

if (text == NULL) {
text_length = 0;
if (mOutlookServer) {
text_length = 0;
}
else {
return MAILIMAP_ERROR_FETCH;
}
}

* result = text;
Expand Down Expand Up @@ -2717,8 +2722,7 @@ Array * IMAPSession::fetchMessagesByNumberWithExtraHeaders(String * folder, IMAP
return result;
}

static int fetch_rfc822(mailimap * session, bool identifier_is_uid,
uint32_t identifier, char ** result, size_t * result_len)
int IMAPSession::fetch_rfc822(mailimap * session, bool identifier_is_uid, uint32_t identifier, char ** result, size_t * result_len)
{
struct mailimap_section * section;
struct mailimap_fetch_att * fetch_att;
Expand Down
5 changes: 5 additions & 0 deletions src/core/imap/MCIMAPSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef __cplusplus

typedef struct mailimap_fetch_type mailimap_fetch_type;

namespace mailcore {

extern String * IMAPNamespacePersonal;
Expand Down Expand Up @@ -273,6 +275,7 @@ namespace mailcore {
bool mRamblerRuServer;
bool mHermesServer;
bool mQipServer;
bool mOutlookServer;

unsigned int mLastFetchedSequenceNumber;
String * mCurrentFolder;
Expand Down Expand Up @@ -322,6 +325,8 @@ namespace mailcore {
bool wholePart, uint32_t offset, uint32_t length,
Encoding encoding, IMAPProgressCallback * progressCallback, ErrorCode * pError);
void storeLabels(String * folder, bool identifier_is_uid, IndexSet * identifiers, IMAPStoreFlagsRequestKind kind, Array * labels, ErrorCode * pError);
int fetch_rfc822(mailimap * session, bool identifier_is_uid, uint32_t identifier, char ** result, size_t * result_len);
int fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier, mailimap_fetch_type * fetch_type, char ** result, size_t * result_len);
};

}
Expand Down

0 comments on commit 8bceb3e

Please sign in to comment.