From:             nick at mailtrust dot com
Operating system: CentOS 5
PHP version:      5.3SVN-2009-10-22 (SVN)
PHP Bug Type:     IMAP related
Bug description:  Add INTERNALDATE to imap_append

Description:
------------
Jake Levitt and I created this patch which adds the option to set a
message's INTERNALDATE when appending it to a mail server using imap.  Any
chance we can get this included into the php 5.3 and 6 development
branches?  The diff below was done against the php-src/branches/PHP_5_3
branch.  If you guys need me to apply the changes to a different branch or
snapshot, please let me know.

Here's the svn diff (done in my repo)... if you need something else please
let me know:


Index: ext/imap/php_imap.c
===================================================================
--- ext/imap/php_imap.c (revision 3399)
+++ ext/imap/php_imap.c (working copy)
@@ -41,6 +41,7 @@
 #include "ext/standard/info.h"
 #include "ext/standard/file.h"
 #include "ext/standard/php_smart_str.h"
+#include "ext/pcre/php_pcre.h"
 
 #ifdef ERROR
 #undef ERROR
@@ -118,6 +119,7 @@
        ZEND_ARG_INFO(0, folder)
        ZEND_ARG_INFO(0, message)
        ZEND_ARG_INFO(0, options)
+       ZEND_ARG_INFO(0, date)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_num_msg, 0, 0, 1)
@@ -1265,25 +1267,48 @@
 }
 /* }}} */
 
-/* {{{ proto bool imap_append(resource stream_id, string folder, string
message [, string options])
+/* {{{ proto bool imap_append(resource stream_id, string folder, string
message [, string options [, string internal_date]])
    Append a new message to a specified mailbox */
 PHP_FUNCTION(imap_append)
 {
        zval *streamind;
-       char *folder, *message, *flags = NULL;
-       int folder_len, message_len, flags_len = 0;
+       char *folder, *message, *internal_date = NULL, *flags = NULL;
+       int folder_len, message_len, internal_date_len = 0, flags_len = 0;
        pils *imap_le_struct;
        STRING st;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss|s",
&streamind, &folder, &folder_len, &message, &message_len, &flags,
&flags_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss|ss",
&streamind, &folder, &folder_len, &message, &message_len, &flags,
&flags_len, &internal_date, &internal_date_len) == FAILURE) {
                return;
        }
 
+       char* regex = "/[
0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4}
[0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/";
+       int regex_len = strlen(regex);
+       pcre_cache_entry *pce;                          /* Compiled regex */
+       zval *subpats = NULL;                           /* Parts (not used) */
+       long regex_flags = 0;                           /* Flags (not used) */
+       long start_offset = 0;                          /* Start offset (not 
used) */
+       int global = 0;
+
+       if (internal_date) {
+               /* Make sure the given internal_date string matches the RFC 
specified
format */
+               if ((pce = pcre_get_compiled_regex_cache(regex, regex_len 
TSRMLS_CC))
== NULL) {
+                       RETURN_FALSE;
+               }
+
+               php_pcre_match_impl(pce, internal_date, internal_date_len,
return_value, subpats, global,
+                       0, regex_flags, start_offset TSRMLS_CC);
+
+               if (!Z_LVAL_P(return_value)) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "internal 
date not
correctly formatted");
+                       internal_date = NULL;
+               }
+       }
+
        ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap",
le_imap);
 
        INIT (&st, mail_string, (void *) message, message_len);
 
-       if (mail_append_full(imap_le_struct->imap_stream, folder, (flags ? flags
: NIL), NIL, &st)) {
+       if (mail_append_full(imap_le_struct->imap_stream, folder, (flags ? flags
: NIL), (internal_date ? internal_date : NIL), &st)) {
                RETURN_TRUE;
        } else {
                RETURN_FALSE;



-- 
Edit bug report at http://bugs.php.net/?id=49960&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49960&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49960&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49960&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49960&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49960&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49960&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49960&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49960&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49960&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49960&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49960&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49960&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49960&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49960&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49960&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49960&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49960&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49960&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49960&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49960&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49960&r=mysqlcfg

Reply via email to