$Log$
+ Revision 591.74 2002/07/28 20:33:13 ajc
+ * Augmented the "headers only" functionality of the message reading API (as
+ well as the options of the server commands which expose it) to allow
+ headers+body, headers only, or body only.
+ * Adjusted message output of IMAP command FETCH BODY[1] when message is in
+ legacy Citadel format. This fixes a bug exposed by SquirrelMail.
+
Revision 591.73 2002/07/23 04:00:06 ajc
* Completed the MSGP and MSG4 commands to set the client's preferred MIME
content types, and fetch messages with MIME content types.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
* Load the message into a temp file for translation and measurement
*/
CtdlRedirectOutput(tmp, -1);
- CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, 0, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, HEADERS_ALL, 0, 1);
CtdlRedirectOutput(NULL, -1);
if (!is_valid_message(msg)) {
lprintf(1, "WARNING: output clobbered the message!\n");
/* Now figure out what the client wants, and get it */
- if (!strcmp(section, "")) { /* the whole thing */
+ if ( (!strcmp(section, "1")) && (msg->cm_format_type != 4) ) {
CtdlRedirectOutput(tmp, -1);
- CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, 0, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822,
+ HEADERS_NONE, 0, 1);
+ CtdlRedirectOutput(NULL, -1);
+ }
+
+ else if (!strcmp(section, "")) {
+ CtdlRedirectOutput(tmp, -1);
+ CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822,
+ HEADERS_ALL, 0, 1);
CtdlRedirectOutput(NULL, -1);
}
*/
else if (!strncasecmp(section, "HEADER", 6)) {
CtdlRedirectOutput(tmp, -1);
- CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, 1, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822,
+ HEADERS_ONLY, 0, 1);
CtdlRedirectOutput(NULL, -1);
imap_strip_headers(tmp, section);
}
return((CC->download_fp != NULL) ? om_ok : om_mime_error);
}
+ /* Does the caller want to skip the headers? */
+ if (headers_only == HEADERS_NONE) goto START_TEXT;
+
/* now for the user-mode message reading loops */
if (do_proto) cprintf("%d Message %ld:\n", LISTING_FOLLOWS, msg_num);
}
/* end header processing loop ... at this point, we're in the text */
-
+START_TEXT:
mptr = TheMessage->cm_fields['M'];
/* Tell the client about the MIME parts in this message */
}
}
- if (headers_only) {
+ if (headers_only == HEADERS_ONLY) {
if (do_proto) cprintf("000\n");
return(om_ok);
}
void cmd_msg0(char *cmdbuf)
{
long msgid;
- int headers_only = 0;
+ int headers_only = HEADERS_ALL;
msgid = extract_long(cmdbuf, 0);
headers_only = extract_int(cmdbuf, 1);
void cmd_msg2(char *cmdbuf)
{
long msgid;
- int headers_only = 0;
+ int headers_only = HEADERS_ALL;
msgid = extract_long(cmdbuf, 0);
headers_only = extract_int(cmdbuf, 1);
om_no_such_msg,
om_mime_error
};
-
+
+/*
+ * Values of "headers_only" when calling message output routines
+ */
+#define HEADERS_ALL 0 /* Headers and body */
+#define HEADERS_ONLY 1 /* Headers only */
+#define HEADERS_NONE 2 /* Body only */
struct ma_info {
POP3->msgs[POP3->num_msgs-1].temp = fp;
CtdlRedirectOutput(fp, -1);
- CtdlOutputMsg(msgnum, MT_RFC822, 0, 0, 1);
+ CtdlOutputMsg(msgnum, MT_RFC822, HEADERS_ALL, 0, 1);
CtdlRedirectOutput(NULL, -1);
POP3->msgs[POP3->num_msgs-1].rfc822_length = ftell(fp);
}
else {
CtdlRedirectOutput(msg_fp, -1);
- CtdlOutputMsg(msgnum, MT_RFC822, 0, 0, 1);
+ CtdlOutputMsg(msgnum, MT_RFC822, HEADERS_ALL, 0, 1);
CtdlRedirectOutput(NULL, -1);
fseek(msg_fp, 0L, SEEK_END);
msg_size = ftell(msg_fp);
/* Message */
CtdlRedirectOutput(NULL, sock);
- CtdlOutputPreLoadedMsg(msg, 0L, MT_RFC822, 0, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, 0L, MT_RFC822, HEADERS_ALL, 0, 1);
CtdlRedirectOutput(NULL, -1);
/* Close one end of the socket connection; this tells SpamAssassin
This is a command used to read the text of a message. "Mode 0" implies that
other MSG commands (MSG1, MSG2, etc.) will probably be added later on to read
messages in more robust formats. This command should be passed two arguments.
-The first is the message number of the message being requested. In server
-version 4.04 and above, the second argument may be set to either 0 to read the
-entire message, or 1 to read the headers only.
-
- The server should, of course, make sure that the client actually has access
-to the message being requested before honoring this request. Citadel/UX does
-so by checking the message number against the contents of the current room. If
-it's not there, the request is denied.
-
+The first is the message number of the message being requested. The second
+argument specifies whether the client wants headers and/or message body:
+ 0 = Headers and body
+ 1 = Headers only
+ 2 = Body only
+
If the request is denied, an ERROR code will be returned. Otherwise, the
LISTING_FOLLOWS code will be returned, followed by the contents of the message.
The following fields may be sent: