Skip to content

Commit

Permalink
lib-imap: Started using struct uri_host in struct imap_url.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanbosch authored and GitLab committed May 16, 2016
1 parent f74dbd3 commit 66134fb
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 117 deletions.
2 changes: 1 addition & 1 deletion src/imap-login/client-authenticate.c
Expand Up @@ -60,7 +60,7 @@ void imap_client_auth_result(struct client *client,
memset(&url, 0, sizeof(url));
url.userid = reply->destuser;
url.auth_type = client->auth_mech_name;
url.host_name = reply->host;
url.host.name = reply->host;
if (reply->port != 143)
url.port = reply->port;
str_append(referral, "REFERRAL ");
Expand Down
2 changes: 1 addition & 1 deletion src/lib-imap-urlauth/imap-urlauth.c
Expand Up @@ -205,7 +205,7 @@ imap_urlauth_check_hostport(struct imap_urlauth_context *uctx,
/* validate host */
/* FIXME: allow host ip/ip6 as well? */
if (strcmp(uctx->url_host, URL_HOST_ALLOW_ANY) != 0 &&
strcmp(url->host_name, uctx->url_host) != 0) {
strcmp(url->host.name, uctx->url_host) != 0) {
*error_r = "Invalid URL: Inappropriate host name";
return FALSE;
}
Expand Down
16 changes: 3 additions & 13 deletions src/lib-imap/imap-url.c
Expand Up @@ -260,8 +260,7 @@ static int imap_url_parse_iserver(struct imap_url_parser *url_parser)
}

if (url != NULL) {
url->host_name = auth.host.name;
url->host_ip = auth.host.ip;
url->host = auth.host;
url->port = auth.port;
}
return 1;
Expand Down Expand Up @@ -837,8 +836,7 @@ static bool imap_url_do_parse(struct imap_url_parser *url_parser)
struct imap_url *url = url_parser->url;
const struct imap_url *base = url_parser->base;

url->host_name = p_strdup_empty(parser->pool, base->host_name);
url->host_ip = base->host_ip;
uri_host_copy(parser->pool, &url->host, &base->host);
url->port = base->port;
url->userid = p_strdup_empty(parser->pool, base->userid);
url->auth_type = p_strdup_empty(parser->pool, base->auth_type);
Expand Down Expand Up @@ -990,15 +988,7 @@ const char *imap_url_create(const struct imap_url *url)
}

/* server */
if (url->host_name != NULL) {
/* assume IPv6 literal if starts with '['; avoid encoding */
if (*url->host_name == '[')
str_append(urlstr, url->host_name);
else
uri_append_host_name(urlstr, url->host_name);
} else {
uri_append_host_ip(urlstr, &url->host_ip);
}
uri_append_host(urlstr, &url->host);
uri_append_port(urlstr, url->port);

/* Older syntax (RFC 2192) requires this slash at all times */
Expand Down
5 changes: 3 additions & 2 deletions src/lib-imap/imap-url.h
@@ -1,10 +1,11 @@
#ifndef IMAP_URL_H
#define IMAP_URL_H

#include "uri-util.h"

struct imap_url {
/* server */
const char *host_name;
struct ip_addr host_ip;
struct uri_host host;
in_port_t port;

/* user */
Expand Down

0 comments on commit 66134fb

Please sign in to comment.