Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ext/standard/mail.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,14 @@ PHPAPI bool php_mail(const char *to, const char *subject, const char *message, c
}

char *line_sep;
const char *cr_lf_mode = PG(mail_cr_lf_mode);
zend_string *cr_lf_mode = PG(mail_cr_lf_mode);

if (cr_lf_mode && strcmp(cr_lf_mode, "crlf") != 0) {
if (strcmp(cr_lf_mode, "lf") == 0) {
if (cr_lf_mode && !zend_string_equals_literal(cr_lf_mode, "crlf")) {
if (zend_string_equals_literal(cr_lf_mode, "lf")) {
line_sep = "\n";
} else if (strcmp(cr_lf_mode, "mixed") == 0) {
} else if (zend_string_equals_literal(cr_lf_mode, "mixed")) {
line_sep = "\n";
} else if (strcmp(cr_lf_mode, "os") == 0) {
} else if (zend_string_equals_literal(cr_lf_mode, "os")) {
#ifdef PHP_WIN32
line_sep = "\r\n";
#else
Expand Down Expand Up @@ -609,7 +609,7 @@ PHPAPI bool php_mail(const char *to, const char *subject, const char *message, c

fprintf(sendmail, "%s", line_sep);

if (cr_lf_mode && strcmp(cr_lf_mode, "lf") == 0) {
if (cr_lf_mode && zend_string_equals_literal(cr_lf_mode, "lf")) {
char *converted_message = NULL;
size_t msg_len = strlen(message);
size_t new_len = 0;
Expand Down
13 changes: 6 additions & 7 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,12 +725,11 @@ static PHP_INI_MH(OnUpdateMailLog)
static PHP_INI_MH(OnUpdateMailCrLfMode)
{
if (new_value) {
const char *val = ZSTR_VAL(new_value);
if (ZSTR_LEN(new_value) > 0 &&
strcmp(val, "crlf") != 0 &&
strcmp(val, "lf") != 0 &&
strcmp(val, "mixed") != 0 &&
strcmp(val, "os") != 0) {
!zend_string_equals_literal(new_value, "crlf") &&
!zend_string_equals_literal(new_value, "lf") &&
!zend_string_equals_literal(new_value, "mixed") &&
!zend_string_equals_literal(new_value, "os")) {
int err_type;

if (stage == ZEND_INI_STAGE_RUNTIME) {
Expand All @@ -740,13 +739,13 @@ static PHP_INI_MH(OnUpdateMailCrLfMode)
}

if (stage != ZEND_INI_STAGE_DEACTIVATE) {
php_error_docref(NULL, err_type, "Invalid value \"%s\" for mail.cr_lf_mode. Must be one of: \"crlf\", \"lf\", \"mixed\", \"os\"", val);
php_error_docref(NULL, err_type, "Invalid value \"%s\" for mail.cr_lf_mode. Must be one of: \"crlf\", \"lf\", \"mixed\", \"os\"", ZSTR_VAL(new_value));
}

return FAILURE;
}
}
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
OnUpdateStr(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
return SUCCESS;
}
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion main/php_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ struct _php_core_globals {
char *request_order;

char *mail_log;
zend_string *mail_cr_lf_mode;
bool mail_x_header;
bool mail_mixed_lf_and_crlf;
char *mail_cr_lf_mode;

bool in_error_log;

Expand Down