]>
Commit | Line | Data |
---|---|---|
f9fed404 AM |
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 | |
5316c927 AF |
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" | |
804cfcec | 11 | #include "ext/standard/info.h" |
8135bbee | 12 | |
f9fed404 AM |
13 | @@ -42,6 +44,8 @@ |
14 | #include "php_string.h" | |
804cfcec AM |
15 | #include "safe_mode.h" |
16 | #include "exec.h" | |
804cfcec | 17 | +#include "zend_operators.h" |
804cfcec | 18 | +#include "zend_globals.h" |
d51e0cbd | 19 | |
804cfcec AM |
20 | #ifdef PHP_WIN32 |
21 | #include "win32/sendmail.h" | |
f9fed404 AM |
22 | @@ -131,6 +135,18 @@ PHP_FUNCTION(mail) |
23 | MAIL_ASCIIZ_CHECK(extra_cmd, extra_cmd_len); | |
16fd5964 ER |
24 | } |
25 | ||
fa59626a | 26 | + /* search for To: and Subject: headers which should be specified in proper mail() parameters, not in additional headers */ |
16fd5964 ER |
27 | + if (headers != NULL) { |
28 | + if (strncasecmp(headers, "to:", sizeof("to:") - 1) == 0 || strcasestr(headers, "\nto:")) { | |
fa59626a AM |
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."); | |
16fd5964 ER |
34 | + RETURN_FALSE; |
35 | + } | |
16fd5964 ER |
36 | + } |
37 | + | |
38 | if (to_len > 0) { | |
39 | to_r = estrndup(to, to_len); | |
40 | for (; to_len; to_len--) { | |
f9fed404 | 41 | @@ -276,8 +292,42 @@ PHPAPI int php_mail(char *to, char *subj |
8135bbee JB |
42 | return 0; |
43 | } | |
44 | #endif | |
5316c927 AF |
45 | - fprintf(sendmail, "To: %s\n", to); |
46 | - fprintf(sendmail, "Subject: %s\n", subject); | |
b9a39e32 | 47 | + TSRMLS_FETCH(); |
edf77de8 | 48 | + |
5316c927 AF |
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 | + } | |
9af7358c | 55 | + zend_is_auto_global(ZEND_STRL("_SERVER") TSRMLS_CC); |
804cfcec AM |
56 | + if (PG(http_globals)[TRACK_VARS_SERVER]) { |
57 | + zval **remote_addr, **server_name, **server_port, | |
bfb8a2ed | 58 | + **script_name, **http_user_agent; |
804cfcec AM |
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); | |
b4e19d31 | 66 | + fprintf(sendmail, "HTTP-Posting-URI: %s", Z_STRVAL_PP(server_name)); |
804cfcec AM |
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 | + } | |
18e705dd | 71 | + if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &script_name)==SUCCESS) { |
bfb8a2ed AM |
72 | + convert_to_string_ex(script_name); |
73 | + fprintf(sendmail, "%s", Z_STRVAL_PP(script_name)); | |
804cfcec AM |
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 | + | |
5316c927 AF |
83 | if (headers != NULL) { |
84 | fprintf(sendmail, "%s\n", headers); | |
85 | } |