Skip to content

Commit 46315de

Browse files
committed
Use locale-independent case conversion in mb_send_mail()
Headers should not be processed in a locale-depdendent fashion. Switch from upper to lowercasing because that's the standard for PHP and we provide an ASCII implementation of this operation. This is adapted from GH-7506.
1 parent a942b28 commit 46315de

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

ext/mbstring/mbstring.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3370,9 +3370,7 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t
33703370

33713371
if (fld_name != NULL && fld_val != NULL) {
33723372
zval val;
3373-
/* FIXME: some locale free implementation is
3374-
* really required here,,, */
3375-
php_strtoupper(ZSTR_VAL(fld_name), ZSTR_LEN(fld_name));
3373+
zend_str_tolower(ZSTR_VAL(fld_name), ZSTR_LEN(fld_name));
33763374
ZVAL_STR(&val, fld_val);
33773375

33783376
zend_hash_update(ht, fld_name, &val);
@@ -3418,11 +3416,8 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t
34183416
}
34193417
if (fld_name != NULL && fld_val != NULL) {
34203418
zval val;
3421-
/* FIXME: some locale free implementation is
3422-
* really required here,,, */
3423-
php_strtoupper(ZSTR_VAL(fld_name), ZSTR_LEN(fld_name));
3419+
zend_str_tolower(ZSTR_VAL(fld_name), ZSTR_LEN(fld_name));
34243420
ZVAL_STR(&val, fld_val);
3425-
34263421
zend_hash_update(ht, fld_name, &val);
34273422

34283423
zend_string_release_ex(fld_name, 0);
@@ -3508,7 +3503,7 @@ PHP_FUNCTION(mb_send_mail)
35083503
_php_mbstr_parse_mail_headers(&ht_headers, ZSTR_VAL(str_headers), ZSTR_LEN(str_headers));
35093504
}
35103505

3511-
if ((s = zend_hash_str_find(&ht_headers, "CONTENT-TYPE", sizeof("CONTENT-TYPE") - 1))) {
3506+
if ((s = zend_hash_str_find(&ht_headers, "content-type", sizeof("content-type") - 1))) {
35123507
char *tmp;
35133508
char *param_name;
35143509
char *charset = NULL;
@@ -3544,7 +3539,7 @@ PHP_FUNCTION(mb_send_mail)
35443539
suppressed_hdrs.cnt_type = 1;
35453540
}
35463541

3547-
if ((s = zend_hash_str_find(&ht_headers, "CONTENT-TRANSFER-ENCODING", sizeof("CONTENT-TRANSFER-ENCODING") - 1))) {
3542+
if ((s = zend_hash_str_find(&ht_headers, "content-transfer-encoding", sizeof("content-transfer-encoding") - 1))) {
35483543
const mbfl_encoding *_body_enc;
35493544

35503545
ZEND_ASSERT(Z_TYPE_P(s) == IS_STRING);
@@ -3640,7 +3635,7 @@ PHP_FUNCTION(mb_send_mail)
36403635
zend_string_release_ex(str_headers, 0);
36413636
}
36423637

3643-
if (!zend_hash_str_exists(&ht_headers, "MIME-VERSION", sizeof("MIME-VERSION") - 1)) {
3638+
if (!zend_hash_str_exists(&ht_headers, "mime-version", sizeof("mime-version") - 1)) {
36443639
mbfl_memory_device_strncat(&device, PHP_MBSTR_MAIL_MIME_HEADER1, sizeof(PHP_MBSTR_MAIL_MIME_HEADER1) - 1);
36453640
mbfl_memory_device_strncat(&device, "\n", 1);
36463641
}

0 commit comments

Comments
 (0)