Index: squid/configure.in diff -c squid/configure.in:1.251.2.40 squid/configure.in:1.251.2.42 *** squid/configure.in:1.251.2.40 Mon Jan 13 16:01:08 2003 --- squid/configure.in Fri Jan 17 18:53:21 2003 *************** *** 780,785 **** --- 780,806 ---- fi ]) + dnl Disable hostname checks + enable_hostname_checks=1 + AC_ARG_ENABLE(hostname_checks, + [ --disable-hostname-checks + Squid by default rejects any host names with + odd characters in their name to conform with + internet standards. If you disagree with this + you may use this switch to turn off any such + checks, provided that the resolver used by + Squid does not reject such host names.. This + may be required to participate in testbeds for + international domain names.], + [ if test "$enableval" = "no"; then + echo "Disabling hostname sanity checks" + enable_hostname_checks=0 + fi + ]) + if test "$enable_hostname_checks" = 1; then + AC_DEFINE(CHECK_HOSTNAMES, 1, [Enable hostname sanity checks]) + fi + dnl Enable underscore in hostnames AC_ARG_ENABLE(underscores, [ --enable-underscores Squid by default rejects any host names with _ Index: squid/src/url.c diff -c squid/src/url.c:1.133.2.3 squid/src/url.c:1.133.2.5 *** squid/src/url.c:1.133.2.3 Wed Sep 11 23:21:00 2002 --- squid/src/url.c Sat Jan 18 07:16:49 2003 *************** *** 106,111 **** --- 106,112 ---- }; static request_t *urnParse(method_t method, char *urn); + #if CHECK_HOSTNAMES static const char *const valid_hostname_chars = #if ALLOW_HOSTNAME_UNDERSCORES "ABCDEFGHIJKLMNOPQRSTUVWXYZ" *************** *** 116,121 **** --- 117,123 ---- "abcdefghijklmnopqrstuvwxyz" "0123456789-."; #endif + #endif /* CHECK_HOSTNAMES */ /* convert %xx in url string to a character * Allocate a new string and return a pointer to converted string */ *************** *** 304,321 **** *q = '0円'; } } if (strspn(host, valid_hostname_chars) != strlen(host)) { debug(23, 1) ("urlParse: Illegal character in hostname '%s'\n", host); return NULL; } /* remove trailing dots from hostnames */ while ((l = strlen(host))> 0 && host[--l] == '.') host[l] = '0円'; ! /* remove duplicate dots */ ! while ((t = strstr(host, ".."))) ! xmemmove(t, t + 1, strlen(t)); ! if (Config.appendDomain && !strchr(host, '.')) ! strncat(host, Config.appendDomain, SQUIDHOSTNAMELEN); if (port < 1 || port> 65535) { debug(23, 3) ("urlParse: Invalid port '%d'\n", port); return NULL; --- 306,327 ---- *q = '0円'; } } + #if CHECK_HOSTNAMES if (strspn(host, valid_hostname_chars) != strlen(host)) { debug(23, 1) ("urlParse: Illegal character in hostname '%s'\n", host); return NULL; } + #endif + if (Config.appendDomain && !strchr(host, '.')) + strncat(host, Config.appendDomain, SQUIDHOSTNAMELEN); /* remove trailing dots from hostnames */ while ((l = strlen(host))> 0 && host[--l] == '.') host[l] = '0円'; ! /* reject duplicate or leading dots */ ! if (strstr(host, "..") || *host == '.') { ! debug(23, 1) ("urlParse: Illegal hostname '%s'\n", host); ! return NULL; ! } if (port < 1 || port> 65535) { debug(23, 3) ("urlParse: Invalid port '%d'\n", port); return NULL; Index: squid/include/autoconf.h.in diff -c squid/include/autoconf.h.in:1.109.2.6 squid/include/autoconf.h.in:1.109.2.7 *** squid/include/autoconf.h.in:1.109.2.6 Mon Jan 13 16:06:31 2003 --- squid/include/autoconf.h.in Fri Jan 17 18:46:33 2003 *************** *** 867,871 **** --- 867,874 ---- /* Version number of package */ #undef VERSION + /* Enable hostname sanity checks */ + #undef CHECK_HOSTNAMES + #endif /* __CONFIGURE_H__ */ Index: squid/configure diff -c squid/configure:1.248.2.41 squid/configure:1.248.2.43 *** squid/configure:1.248.2.41 Mon Jan 13 16:06:26 2003 --- squid/configure Fri Jan 17 18:53:16 2003 *************** *** 149,154 **** --- 149,164 ---- when used with async I/O. Truncate uses more filesystem inodes than unlink.." ac_help="$ac_help + --disable-hostname-checks + Squid by default rejects any host names with + odd characters in their name to conform with + internet standards. If you disagree with this + you may use this switch to turn off any such + checks, provided that the resolver used by + Squid does not reject such host names.. This + may be required to participate in testbeds for + international domain names." + ac_help="$ac_help --enable-underscores Squid by default rejects any host names with _ in their name to conform with internet standards. If you disagree with this you may allow _ in *************** *** 2614,2619 **** --- 2624,2647 ---- fi + enable_hostname_checks=1 + # Check whether --enable-hostname_checks or --disable-hostname_checks was given. + if test "${enable_hostname_checks+set}" = set; then + enableval="$enable_hostname_checks" + if test "$enableval" = "no"; then + echo "Disabling hostname sanity checks" + enable_hostname_checks=0 + fi + + fi + + if test "$enable_hostname_checks" = 1; then + cat>> confdefs.h <<\eof + #define CHECK_HOSTNAMES 1 + EOF + + fi + # Check whether --enable-underscores or --disable-underscores was given. if test "${enable_underscores+set}" = set; then enableval="$enable_underscores"