Skip to content

Commit c5c6bc8

Browse files
committed
- [doc] add support for DISABLE_AUTHENTICATOR in imap_open (fix #33500)
1 parent 8f4337f commit c5c6bc8

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP NEWS
33
?? ??? 20??, PHP 5.3.3
44
- Upgraded bundled libmagic to version 5.03. (Mikko)
55

6+
- Added support for DISABLE_AUTHENTICATOR for imap_open. (Pierre)
67
- Added missing host validation for HTTP urls inside FILTER_VALIDATE_URL.
78
(Ilia)
89
- Added stream_resolve_include_path(). (Mikko)

ext/imap/php_imap.c

+44-2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_open, 0, 0, 3)
105105
ZEND_ARG_INFO(0, password)
106106
ZEND_ARG_INFO(0, options)
107107
ZEND_ARG_INFO(0, n_retries)
108+
ZEND_ARG_INFO(0, params)
108109
ZEND_END_ARG_INFO()
109110

110111
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_reopen, 0, 0, 2)
@@ -1148,10 +1149,11 @@ static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
11481149
long retries = 0, flags = NIL, cl_flags = NIL;
11491150
MAILSTREAM *imap_stream;
11501151
pils *imap_le_struct;
1152+
zval *params = NULL;
11511153
int argc = ZEND_NUM_ARGS();
11521154

1153-
if (zend_parse_parameters(argc TSRMLS_CC, "sss|ll", &mailbox, &mailbox_len, &user, &user_len,
1154-
&passwd, &passwd_len, &flags, &retries) == FAILURE) {
1155+
if (zend_parse_parameters(argc TSRMLS_CC, "sss|lla", &mailbox, &mailbox_len, &user, &user_len,
1156+
&passwd, &passwd_len, &flags, &retries, &params) == FAILURE) {
11551157
return;
11561158
}
11571159

@@ -1165,6 +1167,46 @@ static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
11651167
}
11661168
}
11671169

1170+
if (params) {
1171+
zval **disabled_auth_method;
1172+
1173+
if (zend_hash_find(HASH_OF(params), "DISABLE_AUTHENTICATOR", sizeof("DISABLE_AUTHENTICATOR"), (void **)&disabled_auth_method) == SUCCESS) {
1174+
switch (Z_TYPE_PP(disabled_auth_method)) {
1175+
case IS_STRING:
1176+
if (Z_STRLEN_PP(disabled_auth_method) > 1) {
1177+
mail_parameters (NIL, DISABLE_AUTHENTICATOR, (void *)Z_STRVAL_PP(disabled_auth_method));
1178+
}
1179+
break;
1180+
case IS_ARRAY:
1181+
{
1182+
zval **z_auth_method;
1183+
int i;
1184+
int nelems = zend_hash_num_elements(Z_ARRVAL_PP(disabled_auth_method));
1185+
1186+
if (nelems == 0 ) {
1187+
break;
1188+
}
1189+
for (i = 0; i < nelems; i++) {
1190+
if (zend_hash_index_find(Z_ARRVAL_PP(disabled_auth_method), i, (void **) &z_auth_method) == SUCCESS) {
1191+
if (Z_TYPE_PP(z_auth_method) == IS_STRING) {
1192+
if (Z_STRLEN_PP(z_auth_method) > 1) {
1193+
mail_parameters (NIL, DISABLE_AUTHENTICATOR, (void *)Z_STRVAL_PP(disabled_auth_method));
1194+
}
1195+
} else {
1196+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument, expect string or array of strings");
1197+
}
1198+
}
1199+
}
1200+
}
1201+
break;
1202+
case IS_LONG:
1203+
default:
1204+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument, expect string or array of strings");
1205+
break;
1206+
}
1207+
}
1208+
}
1209+
11681210
if (IMAPG(imap_user)) {
11691211
efree(IMAPG(imap_user));
11701212
}

0 commit comments

Comments
 (0)