Skip to content

Commit 00543a4

Browse files
committed
ext/standard/mail.c: Refactor php_mail_build_headers_check_field_name()
1 parent 63bd25d commit 00543a4

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
@@ -109,14 +109,13 @@ static php_mail_header_value_error_type php_mail_build_headers_check_field_value
109109

110110
static bool php_mail_build_headers_check_field_name(const zend_string *key)
111111
{
112-
size_t len = 0;
112+
const char *end = ZSTR_VAL(key) + ZSTR_LEN(key);
113113

114114
/* https://tools.ietf.org/html/rfc2822#section-2.2 */
115-
while (len < ZSTR_LEN(key)) {
116-
if (*(ZSTR_VAL(key)+len) < 33 || *(ZSTR_VAL(key)+len) > 126 || *(ZSTR_VAL(key)+len) == ':') {
115+
for (const char *ptr = ZSTR_VAL(key); ptr < end; ptr++) {
116+
if (*ptr < 33 || *ptr > 126 || *ptr == ':') {
117117
return false;
118118
}
119-
len++;
120119
}
121120
return true;
122121
}

0 commit comments

Comments
 (0)