]> git.pld-linux.org Git - packages/php.git/blame - php-mail.patch
up to php-7.2.0RC6, likely last RC
[packages/php.git] / php-mail.patch
CommitLineData
c0240cb1 1--- php-5.2.0/ext/standard/mail.c 2006-12-01 14:20:27.881416250 +0100
2+++ php-5.2.4/ext/standard/mail.c 2007-08-31 19:25:50.777713042 +0300
c0240cb1 3@@ -35,6 +37,8 @@
4 #include "php_ini.h"
5 #include "safe_mode.h"
6 #include "exec.h"
7+#include "zend_operators.h"
8+#include "zend_globals.h"
9
10 #ifdef PHP_WIN32
11 #include "win32/sendmail.h"
12@@ -107,6 +111,18 @@
13 return;
14 }
15
16+ /* search for To: and Subject: headers which should be specified in proper mail() parameters, not in additional headers */
17+ if (headers != NULL) {
18+ if (strncasecmp(headers, "to:", sizeof("to:") - 1) == 0 || strcasestr(headers, "\nto:")) {
19+ 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.");
20+ RETURN_FALSE;
21+ }
22+ if (strncasecmp(headers, "subject:", sizeof("subject:") - 1) == 0 || strcasestr(headers, "\nsubject:")) {
23+ 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.");
24+ RETURN_FALSE;
25+ }
26+ }
27+
28 if (to_len > 0) {
29 to_r = estrndup(to, to_len);
30 for (; to_len; to_len--) {
31@@ -231,8 +247,42 @@
32 return 0;
33 }
34 #endif
35- fprintf(sendmail, "To: %s\n", to);
36- fprintf(sendmail, "Subject: %s\n", subject);
37+ TSRMLS_FETCH();
6737bc38
ER
38+
39+ if ((to != NULL) && (strlen(to)!=0)) {
c0240cb1 40+ fprintf(sendmail, "To: %s\n", to);
41+ }
42+ if ((subject != NULL) && (strlen(subject)!=0)) {
43+ fprintf(sendmail, "Subject: %s\n", subject);
44+ }
6131380a 45+ zend_is_auto_global(ZEND_STRL("_SERVER") TSRMLS_CC);
c0240cb1 46+ if (PG(http_globals)[TRACK_VARS_SERVER]) {
47+ zval **remote_addr, **server_name, **server_port,
48+ **script_name, **http_user_agent;
6737bc38 49+
c0240cb1 50+ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "REMOTE_ADDR", sizeof("REMOTE_ADDR"), (void **) &remote_addr)==SUCCESS) {
51+ convert_to_string_ex(remote_addr);
52+ fprintf(sendmail, "HTTP-Posting-Client: %s\n", Z_STRVAL_PP(remote_addr));
53+ }
54+ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name)==SUCCESS) {
55+ convert_to_string_ex(server_name);
56+ fprintf(sendmail, "HTTP-Posting-URI: %s", Z_STRVAL_PP(server_name));
57+ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_PORT", sizeof("SERVER_PORT"), (void **) &server_port)==SUCCESS) {
58+ convert_to_string_ex(server_port);
59+ fprintf(sendmail, ":%s", Z_STRVAL_PP(server_port));
6737bc38 60+ }
c0240cb1 61+ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &script_name)==SUCCESS) {
62+ convert_to_string_ex(script_name);
63+ fprintf(sendmail, "%s", Z_STRVAL_PP(script_name));
64+ }
65+ fprintf(sendmail, "\n");
66+ }
67+ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &http_user_agent)==SUCCESS) {
68+ convert_to_string_ex(http_user_agent);
69+ fprintf(sendmail, "HTTP-Posting-User-Agent: %s\n", Z_STRVAL_PP(http_user_agent));
70+ }
71+ }
72+
73 if (hdr != NULL) {
74 fprintf(sendmail, "%s\n", hdr);
75 }
This page took 0.044692 seconds and 4 git commands to generate.