diff --git a/src/cookies/cookies.c b/src/cookies/cookies.c index 639e8a60..f3616664 100644 --- a/src/cookies/cookies.c +++ b/src/cookies/cookies.c @@ -601,32 +601,6 @@ accept_cookie_never(void *idp) } #endif -/* Check whether domain is matching server - * Ie. - * example.com matches www.example.com/ - * example.com doesn't match www.example.com.org/ - * example.com doesn't match www.example.comm/ - * example.com doesn't match example.co - */ -static int -is_in_domain(unsigned char *domain, unsigned char *server, int server_len) -{ - int domain_len = strlen(domain); - int len; - - if (domain_len > server_len) - return 0; - - if (domain_len == server_len) - return !strncasecmp(domain, server, server_len); - - len = server_len - domain_len; - if (server[len - 1] != '.') - return 0; - - return !strncasecmp(domain, server + len, domain_len); -} - static inline int is_path_prefix(unsigned char *d, unsigned char *s) diff --git a/src/protocol/uri.c b/src/protocol/uri.c index 9da2e9ee..5130ec2a 100644 --- a/src/protocol/uri.c +++ b/src/protocol/uri.c @@ -57,6 +57,25 @@ is_uri_dir_sep(const struct uri *uri, unsigned char pos) } +int +is_in_domain(unsigned char *domain, unsigned char *server, int server_len) +{ + int domain_len = strlen(domain); + int len; + + if (domain_len > server_len) + return 0; + + if (domain_len == server_len) + return !strncasecmp(domain, server, server_len); + + len = server_len - domain_len; + if (server[len - 1] != '.') + return 0; + + return !strncasecmp(domain, server + len, domain_len); +} + int is_ip_address(const unsigned char *address, int addresslen) { diff --git a/src/protocol/uri.h b/src/protocol/uri.h index 426bd11c..93c5cdc4 100644 --- a/src/protocol/uri.h +++ b/src/protocol/uri.h @@ -319,4 +319,13 @@ get_real_uri_length(struct uri *uri) /* Checks if @address contains a valid IP address. */ int is_ip_address(const unsigned char *address, int addresslen); +/* Check whether domain is matching server + * Ie. + * example.com matches www.example.com/ + * example.com doesn't match www.example.com.org/ + * example.com doesn't match www.example.comm/ + * example.com doesn't match example.co + */ +int is_in_domain(unsigned char *domain, unsigned char *server, int server_len); + #endif