diff --git a/ext/standard/mail.c b/ext/standard/mail.c index fb9db686124e8..f6161782bdd76 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -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 @@ -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; diff --git a/main/main.c b/main/main.c index a1515911fbfeb..db7de754143ac 100644 --- a/main/main.c +++ b/main/main.c @@ -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) { @@ -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; } /* }}} */ diff --git a/main/php_globals.h b/main/php_globals.h index 028089ab43c69..893bf25d26cb5 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -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;