Skip to content

Commit 81ad20e

Browse files
committed
ext/standard/mail.c: Refactor php_mail_build_headers_check_field_name()
1 parent a1eb4e5 commit 81ad20e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ext/standard/mail.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,13 @@ static php_mail_header_value_error_type php_mail_build_headers_check_field_value
101101

102102
static bool php_mail_build_headers_check_field_name(const zend_string *key)
103103
{
104-
size_t len = 0;
104+
const char *end = ZSTR_VAL(key) + ZSTR_LEN(key);
105105

106106
/* https://tools.ietf.org/html/rfc2822#section-2.2 */
107-
while (len < ZSTR_LEN(key)) {
108-
if (*(ZSTR_VAL(key)+len) < 33 || *(ZSTR_VAL(key)+len) > 126 || *(ZSTR_VAL(key)+len) == ':') {
107+
for (const char *ptr = ZSTR_VAL(key); ptr < end; ptr++) {
108+
if (*ptr < 33 || *ptr > 126 || *ptr == ':') {
109109
return false;
110110
}
111-
len++;
112111
}
113112
return true;
114113
}

0 commit comments

Comments
 (0)