summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-10-31 14:31:06 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2014-10-31 14:31:06 +0000
commit98b6d02df61ce2917b001c4647d8c6b623b610e7 (patch)
treeabbd2661d70bca9cab6c31004220362a43042154 /utils
parent02ff3920ce22f4a4120cab8cee3a72a244604732 (diff)
downloadnetsurf-98b6d02df61ce2917b001c4647d8c6b623b610e7.tar.gz
netsurf-98b6d02df61ce2917b001c4647d8c6b623b610e7.tar.bz2
Move host_is_ip_address into urldb, as that's the only thing that cares.
Diffstat (limited to 'utils')
-rw-r--r--utils/url.c85
-rw-r--r--utils/url.h13
2 files changed, 0 insertions, 98 deletions
diff --git a/utils/url.c b/utils/url.c
index b32a7346f..450d47188 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -32,91 +32,6 @@
#include "utils/url.h"
-
-/* exported interface documented in utils/url.h */
-bool url_host_is_ip_address(const char *host)
-{
- struct in_addr ipv4;
- size_t host_len = strlen(host);
- const char *sane_host;
- const char *slash;
-#ifndef NO_IPV6
- struct in6_addr ipv6;
- char ipv6_addr[64];
-#endif
- /** @todo FIXME Some parts of urldb.c (and perhaps other parts of
- * NetSurf) make confusions between hosts and "prefixes", we can
- * sometimes be erroneously passed more than just a host. Sometimes
- * we may be passed trailing slashes, or even whole path segments.
- * A specific criminal in this class is urldb_iterate_partial, which
- * takes a prefix to search for, but passes that prefix to functions
- * that expect only hosts.
- *
- * For the time being, we will accept such calls; we check if there
- * is a / in the host parameter, and if there is, we take a copy and
- * replace the / with a \0. This is not a permanent solution; we
- * should search through NetSurf and find all the callers that are
- * in error and fix them. When doing this task, it might be wise
- * to replace the hideousness below with code that doesn't have to do
- * this, and add assert(strchr(host, '/') == NULL); somewhere.
- * -- rjek - 2010-11-04
- */
-
- slash = strchr(host, '/');
- if (slash == NULL) {
- sane_host = host;
- } else {
- char *c = strdup(host);
- c[slash - host] = '\0';
- sane_host = c;
- host_len = slash - host - 1;
- LOG(("WARNING: called with non-host '%s'", host));
- }
-
- if (strspn(sane_host, "0123456789abcdefABCDEF[].:") < host_len)
- goto out_false;
-
- if (inet_aton(sane_host, &ipv4) != 0) {
- /* This can only be a sane IPv4 address if it contains 3 dots.
- * Helpfully, inet_aton is happy to treat "a", "a.b", "a.b.c",
- * and "a.b.c.d" as valid IPv4 address strings where we only
- * support the full, dotted-quad, form.
- */
- int num_dots = 0;
- size_t index;
-
- for (index = 0; index < host_len; index++) {
- if (sane_host[index] == '.')
- num_dots++;
- }
-
- if (num_dots == 3)
- goto out_true;
- else
- goto out_false;
- }
-
-#ifndef NO_IPV6
- if (sane_host[0] != '[' || sane_host[host_len] != ']')
- goto out_false;
-
- strncpy(ipv6_addr, sane_host + 1, sizeof(ipv6_addr));
- ipv6_addr[sizeof(ipv6_addr) - 1] = '\0';
-
- if (inet_pton(AF_INET6, ipv6_addr, &ipv6) == 1)
- goto out_true;
-#endif
-
-out_false:
- if (slash != NULL) free((void *)sane_host);
- return false;
-
-out_true:
- if (slash != NULL) free((void *)sane_host);
- return true;
-}
-
-
/* exported interface documented in utils/url.h */
nserror url_unescape(const char *str, char **result)
{
diff --git a/utils/url.h b/utils/url.h
index 627bb5cb8..d6c5b917c 100644
--- a/utils/url.h
+++ b/utils/url.h
@@ -35,19 +35,6 @@
/**
- * Check whether a host string is an IP address.
- *
- * This call detects IPv4 addresses (all of dotted-quad or subsets,
- * decimal or hexadecimal notations) and IPv6 addresses (including
- * those containing embedded IPv4 addresses.)
- *
- * \param host a hostname terminated by '\0'
- * \return true if the hostname is an IP address, false otherwise
- */
-bool url_host_is_ip_address(const char *host);
-
-
-/**
* Escape a string suitable for inclusion in an URL.
*
* \param unescaped the unescaped string