string_t *str;
int ret;
- if (!str_begins(line, "* OK ", &line)) {
+ if (!str_begins_icase(line, "* OK ", &line)) {
const char *reason = t_strdup_printf("Invalid banner: %s",
str_sanitize(line, 160));
login_proxy_failed(client->common.login_proxy,
}
str = t_str_new(128);
- if (str_begins(line, "[CAPABILITY ", &suffix)) {
+ if (str_begins_icase(line, "[CAPABILITY ", &suffix)) {
capabilities = t_strsplit(t_strcut(suffix, ']'), " ");
if (str_array_icase_find(capabilities, "SASL-IR"))
client->proxy_sasl_ir = TRUE;
imap_client->proxy_sent_state &= ENUM_NEGATE(IMAP_PROXY_SENT_STATE_STARTTLS);
imap_client->proxy_rcvd_state = IMAP_PROXY_RCVD_STATE_STARTTLS;
- if (!str_begins_with(suffix, "OK ")) {
+ if (!str_begins_icase_with(suffix, "OK ")) {
/* STARTTLS failed */
const char *reason = t_strdup_printf(
"STARTTLS failed: %s",
return -1;
o_stream_nsend(output, str_data(str), str_len(str));
return 1;
- } else if (str_begins(line, "L OK ", &suffix)) {
+ } else if (str_begins_icase(line, "L OK ", &suffix)) {
/* Login successful. Send this line to client. */
imap_client->proxy_sent_state &= ENUM_NEGATE(IMAP_PROXY_SENT_STATE_LOGIN);
imap_client->proxy_rcvd_state = IMAP_PROXY_RCVD_STATE_LOGIN;
enum login_proxy_failure_type failure_type =
LOGIN_PROXY_FAILURE_TYPE_AUTH_REPLIED;
#define STR_NO_IMAP_RESP_CODE_AUTHFAILED "NO ["IMAP_RESP_CODE_AUTHFAILED"]"
- if (str_begins_with(line, STR_NO_IMAP_RESP_CODE_AUTHFAILED)) {
+ if (str_begins_icase_with(line, STR_NO_IMAP_RESP_CODE_AUTHFAILED)) {
/* the remote sent a generic "authentication failed"
error. replace it with our one, so that in case
the remote is sending a different error message
client_send_reply_code(client, IMAP_CMD_REPLY_NO,
IMAP_RESP_CODE_AUTHFAILED,
AUTH_FAILED_MSG);
- } else if (str_begins_with(line, "NO [")) {
+ } else if (str_begins_icase_with(line, "NO [")) {
/* remote sent some other resp-code. forward it. */
if (auth_resp_code_is_tempfail(line + 4))
failure_type = LOGIN_PROXY_FAILURE_TYPE_AUTH_TEMPFAIL;
/* Reply to CAPABILITY command we sent */
imap_client->proxy_sent_state &= ENUM_NEGATE(IMAP_PROXY_SENT_STATE_CAPABILITY);
imap_client->proxy_rcvd_state = IMAP_PROXY_RCVD_STATE_CAPABILITY;
- if (str_begins_with(line, "C OK ") &&
+ if (str_begins_icase_with(line, "C OK ") &&
HAS_NO_BITS(imap_client->proxy_sent_state,
IMAP_PROXY_SENT_STATE_AUTHENTICATE |
IMAP_PROXY_SENT_STATE_LOGIN)) {
} else if (str_begins_icase_with(line, "* ID ")) {
/* Reply to ID command we sent, ignore it */
return 0;
- } else if (str_begins(line, "* MULTIPLEX ", &suffix)) {
+ } else if (str_begins_icase(line, "* MULTIPLEX ", &suffix)) {
if (strcmp(suffix, "0") != 0) {
const char *reason = t_strdup_printf(
"Unsupported MULTIPLEX version: %s", suffix);
login_proxy_multiplex_input_start(client->login_proxy);
/* force caller to refresh istream */
return 1;
- } else if (str_begins_with(line, "* BYE ")) {
+ } else if (str_begins_icase_with(line, "* BYE ")) {
/* Login unexpectedly failed (due to some internal error).
Don't forward the BYE to the client, since we're not going
to disconnect it. It could be a possibility to convert these