]> git.pld-linux.org Git - packages/php.git/blob - php-mail.patch
Release 41 (by relup.sh)
[packages/php.git] / php-mail.patch
1 diff -urNp -x '*.orig' php-5.2.17.org/ext/standard/mail.c php-5.2.17/ext/standard/mail.c
2 --- php-5.2.17.org/ext/standard/mail.c  2010-07-19 15:38:53.000000000 +0200
3 +++ php-5.2.17/ext/standard/mail.c      2021-10-23 18:57:39.619791815 +0200
4 @@ -21,6 +21,8 @@
5  #include <stdlib.h>
6  #include <ctype.h>
7  #include <stdio.h>
8 +#include <syslog.h>
9 +#include <string.h>
10  #include "php.h"
11  #include "ext/standard/info.h"
12  
13 @@ -42,6 +44,8 @@
14  #include "php_string.h"
15  #include "safe_mode.h"
16  #include "exec.h"
17 +#include "zend_operators.h"
18 +#include "zend_globals.h"
19  
20  #ifdef PHP_WIN32
21  #include "win32/sendmail.h"
22 @@ -131,6 +135,18 @@ PHP_FUNCTION(mail)
23                 MAIL_ASCIIZ_CHECK(extra_cmd, extra_cmd_len);
24         }
25  
26 +    /* search for To: and Subject: headers which should be specified in proper mail() parameters, not in additional headers */
27 +    if (headers != NULL) {
28 +        if (strncasecmp(headers, "to:", sizeof("to:") - 1) == 0 || strcasestr(headers, "\nto:")) {
29 +            php_error_docref(NULL TSRMLS_CC, E_WARNING, "To: headers aren't allowed in the additional_headers parameter. Use $to parameter for that. Mail not sent.");
30 +            RETURN_FALSE;
31 +        }
32 +        if (strncasecmp(headers, "subject:", sizeof("subject:") - 1) == 0 || strcasestr(headers, "\nsubject:")) {
33 +            php_error_docref(NULL TSRMLS_CC, E_WARNING, "Subject: headers aren't allowed in the additional_headers parameter. Use $subject parameter for that. Mail not sent.");
34 +            RETURN_FALSE;
35 +        }
36 +    }
37 +
38         if (to_len > 0) {
39                 to_r = estrndup(to, to_len);
40                 for (; to_len; to_len--) {
41 @@ -276,8 +292,42 @@ PHPAPI int php_mail(char *to, char *subj
42                         return 0;
43                 }
44  #endif
45 -               fprintf(sendmail, "To: %s\n", to);
46 -               fprintf(sendmail, "Subject: %s\n", subject);
47 +               TSRMLS_FETCH();
48 +               
49 +               if ((to != NULL) && (strlen(to)!=0)) { 
50 +                       fprintf(sendmail, "To: %s\n", to);
51 +               }
52 +               if ((subject != NULL) && (strlen(subject)!=0)) {
53 +                       fprintf(sendmail, "Subject: %s\n", subject);
54 +               }
55 +               zend_is_auto_global(ZEND_STRL("_SERVER") TSRMLS_CC);
56 +               if (PG(http_globals)[TRACK_VARS_SERVER]) {
57 +                       zval **remote_addr, **server_name, **server_port,
58 +                               **script_name, **http_user_agent;
59 +                       
60 +                       if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "REMOTE_ADDR", sizeof("REMOTE_ADDR"), (void **) &remote_addr)==SUCCESS) {
61 +                               convert_to_string_ex(remote_addr);
62 +                               fprintf(sendmail, "HTTP-Posting-Client: %s\n", Z_STRVAL_PP(remote_addr));
63 +                       }
64 +                       if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name)==SUCCESS) {
65 +                               convert_to_string_ex(server_name);
66 +                               fprintf(sendmail, "HTTP-Posting-URI: %s", Z_STRVAL_PP(server_name));
67 +                               if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_PORT", sizeof("SERVER_PORT"), (void **) &server_port)==SUCCESS) {
68 +                                       convert_to_string_ex(server_port);
69 +                                       fprintf(sendmail, ":%s", Z_STRVAL_PP(server_port));
70 +                               }       
71 +                               if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &script_name)==SUCCESS) {
72 +                                       convert_to_string_ex(script_name);
73 +                                       fprintf(sendmail, "%s", Z_STRVAL_PP(script_name));
74 +                               }
75 +                               fprintf(sendmail, "\n");
76 +                       }
77 +                       if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &http_user_agent)==SUCCESS) {
78 +                               convert_to_string_ex(http_user_agent);
79 +                                       fprintf(sendmail, "HTTP-Posting-User-Agent: %s\n", Z_STRVAL_PP(http_user_agent));
80 +                       }
81 +               }
82 +
83                 if (headers != NULL) {
84                         fprintf(sendmail, "%s\n", headers);
85                 }
This page took 0.03275 seconds and 3 git commands to generate.