Skip to content

Commit d824d83

Browse files
author
Sergei Epatov
committed
Fix do not return error on empty part returned from server, return just zero length (2)
1 parent a8c3190 commit d824d83

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/core/imap/MCIMAPSession.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ void IMAPSession::init()
398398
mRamblerRuServer = false;
399399
mHermesServer = false;
400400
mQipServer = false;
401+
mOutlookServer = false;
401402
mLastFetchedSequenceNumber = 0;
402403
mCurrentFolder = NULL;
403404
pthread_mutex_init(&mIdleLock, NULL);
@@ -719,6 +720,7 @@ void IMAPSession::connect(ErrorCode * pError)
719720
mRamblerRuServer = (mHostname->locationOfString(MCSTR(".rambler.ru")) != -1);
720721
mHermesServer = (mWelcomeString->locationOfString(MCSTR("Hermes")) != -1);
721722
mQipServer = (mWelcomeString->locationOfString(MCSTR("QIP IMAP server")) != -1);
723+
mOutlookServer = (mHostname->locationOfString(MCSTR(".outlook.com")) != -1);
722724
}
723725

724726
mState = STATE_CONNECTED;
@@ -1989,10 +1991,8 @@ void IMAPSession::expunge(String * folder, ErrorCode * pError)
19891991
* pError = ErrorNone;
19901992
}
19911993

1992-
static int
1993-
fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier,
1994-
struct mailimap_fetch_type * fetch_type,
1995-
char ** result, size_t * result_len)
1994+
int IMAPSession::fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier,
1995+
mailimap_fetch_type * fetch_type, char ** result, size_t * result_len)
19961996
{
19971997
int r;
19981998
struct mailimap_msg_att * msg_att;
@@ -2051,7 +2051,12 @@ fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier,
20512051
mailimap_fetch_list_free(fetch_result);
20522052

20532053
if (text == NULL) {
2054-
text_length = 0;
2054+
if (mOutlookServer) {
2055+
text_length = 0;
2056+
}
2057+
else {
2058+
return MAILIMAP_ERROR_FETCH;
2059+
}
20552060
}
20562061

20572062
* result = text;
@@ -2717,8 +2722,7 @@ Array * IMAPSession::fetchMessagesByNumberWithExtraHeaders(String * folder, IMAP
27172722
return result;
27182723
}
27192724

2720-
static int fetch_rfc822(mailimap * session, bool identifier_is_uid,
2721-
uint32_t identifier, char ** result, size_t * result_len)
2725+
int IMAPSession::fetch_rfc822(mailimap * session, bool identifier_is_uid, uint32_t identifier, char ** result, size_t * result_len)
27222726
{
27232727
struct mailimap_section * section;
27242728
struct mailimap_fetch_att * fetch_att;

src/core/imap/MCIMAPSession.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#ifdef __cplusplus
1010

11+
typedef struct mailimap_fetch_type mailimap_fetch_type;
12+
1113
namespace mailcore {
1214

1315
extern String * IMAPNamespacePersonal;
@@ -273,6 +275,7 @@ namespace mailcore {
273275
bool mRamblerRuServer;
274276
bool mHermesServer;
275277
bool mQipServer;
278+
bool mOutlookServer;
276279

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

327332
}

0 commit comments

Comments
 (0)