sniper          Wed Jan 19 12:38:32 2005 EDT

  Modified files:              (Branch: PHP_5_0)
    /php-src/win32      sendmail.c 
  Log:
  MFH: - Fixed bug #28976 (use From: from headers if sendmail_from is empty)
  
http://cvs.php.net/diff.php/php-src/win32/sendmail.c?r1=1.59&r2=1.59.2.1&ty=u
Index: php-src/win32/sendmail.c
diff -u php-src/win32/sendmail.c:1.59 php-src/win32/sendmail.c:1.59.2.1
--- php-src/win32/sendmail.c:1.59       Mon Dec  8 17:10:42 2003
+++ php-src/win32/sendmail.c    Wed Jan 19 12:38:32 2005
@@ -17,7 +17,7 @@
  *
  */
 
-/* $Id: sendmail.c,v 1.59 2003/12/08 22:10:42 fmk Exp $ */
+/* $Id: sendmail.c,v 1.59.2.1 2005/01/19 17:38:32 sniper Exp $ */
 
 #include "php.h"                               /*php specific */
 #include <stdio.h>
@@ -225,6 +225,7 @@
        int ret;
        char *RPath = NULL;
        char *headers_lc = NULL; /* headers_lc is only created if we've a 
header at all */
+       char *pos1 = NULL, *pos2 = NULL;
        TSRMLS_FETCH();
 
 #ifndef NETWARE
@@ -266,9 +267,21 @@
        /* Fall back to sendmail_from php.ini setting */
        if (mailRPath && *mailRPath) {
                RPath = estrdup(mailRPath);
-       }
-       else if (INI_STR("sendmail_from")) {
+       } else if (INI_STR("sendmail_from")) {
                RPath = estrdup(INI_STR("sendmail_from"));
+       } else if (     headers_lc &&
+                               (pos1 = strstr(headers_lc, "from:")) &&
+                               ((pos1 == headers_lc) || (*(pos1-1) == '\n'))
+       ) {
+               /* Real offset is memaddress from the original headers + 
difference of
+                * string found in the lowercase headrs + 5 characters to jump 
over   
+                * the from: */
+               pos1 = headers + (pos1 - headers_lc) + 5;
+               if (NULL == (pos2 = strstr(pos1, "\r\n"))) {
+                       RPath = estrndup(pos1, strlen(pos1));
+               } else {
+                       RPath = estrndup(pos1, pos2-pos1);
+               }
        } else {
                if (headers) {
                        efree(headers);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to