Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail on empty part, just return zero length #1621

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## MailCore 2: Introduction ##
## MailCore 2: Introduction ##
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you revert that part?


MailCore 2 provides a simple and asynchronous Objective-C API to work with the e-mail protocols **IMAP**, **POP** and **SMTP**. The API has been redesigned from the ground up. It features:

Expand Down
21 changes: 13 additions & 8 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 @@ -2050,8 +2050,14 @@ fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier,

mailimap_fetch_list_free(fetch_result);

if (text == NULL)
return MAILIMAP_ERROR_FETCH;
if (text == NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you enable that behavior only if outlook server is detected?

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

* result = text;
* result_len = text_length;
Expand Down Expand Up @@ -2716,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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if that data type wasn't public.


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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are those part of the change?

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