cvs: /php3/functions imap.c
| From: | Charles Hagenbuch | Date: | Fri, 14 Apr 2000 04:08:35 +0000 |
| Subject: | cvs: /php3/functions imap.c | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-17897@lists.php.net to get a copy of this message | ||
chagenbu Thu Apr 13 21:08:35 2000 EDT
Modified files:
/php3/functions imap.c
Log:
Fix the logic in imap_fetchheader so that it doesn't incorrectly reject some
message numbers.
Index: php3/functions/imap.c
diff -u php3/functions/imap.c:1.87 php3/functions/imap.c:1.88
--- php3/functions/imap.c:1.87 Sat Mar 25 20:29:35 2000
+++ php3/functions/imap.c Thu Apr 13 21:08:04 2000
@@ -33,7 +33,7 @@
| Andrew Skalski <askalski@chek.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: imap.c,v 1.87 2000/03/26 04:29:35 chagenbu Exp $ */
+/* $Id: imap.c,v 1.88 2000/04/14 04:08:04 chagenbu Exp $ */
#define IMAP41
@@ -2937,32 +2937,39 @@
Get the full unfiltered header for a message */
void php3_imap_fetchheader(INTERNAL_FUNCTION_PARAMETERS)
{
- pval *streamind, * msgno, * flags;
- int ind, ind_type;
+ pval *streamind, *msgno, *flags;
+ int ind, ind_type, msgindex;
pils *imap_le_struct;
int myargc = ARG_COUNT(ht);
if (myargc < 2 || myargc > 3 ||
getParameters(ht,myargc,&streamind,&msgno,&flags) == FAILURE) {
WRONG_PARAM_COUNT;
}
-
+
convert_to_long(streamind);
convert_to_long(msgno);
- if(myargc == 3) convert_to_long(flags);
+ if (myargc == 3) convert_to_long(flags);
ind = streamind->value.lval;
-
+
imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
if (!imap_le_struct || !IS_STREAM(ind_type)) {
php3_error(E_WARNING, "Unable to find stream pointer");
RETURN_FALSE;
}
- if ((msgno->value.lval < 1) || (msgno->value.lval >
imap_le_struct->imap_stream->nmsgs)) {
+ if ((myargc == 3) && (flags->value.lval & FT_UID)) {
+ /* This should be cached; if it causes an extra RTT to the
+ IMAP server, then that's the price we pay for making sure
+ we don't crash. */
+ msgindex = mail_msgno(imap_le_struct->imap_stream, msgno->value.lval);
+ } else {
+ msgindex = msgno->value.lval;
+ }
+ if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) {
php3_error(E_WARNING, "Bad message number");
RETURN_FALSE;
}
RETVAL_STRING(mail_fetchheader_full
(imap_le_struct->imap_stream,msgno->value.lval,NIL,NIL,myargc == 3 ? flags->value.lval :
NIL),1);
-
}
/* }}} */