mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Move is_in_domain from cookies/cookies.c to protocol/uri.c and export
This commit is contained in:
parent
7f042a49d7
commit
9a5f76dbd5
@ -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)
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user