From: serassio <> Date: Sat, 7 Apr 2007 15:35:37 +0000 (+0000) Subject: Bug #1931: allow_underscore directive not available in Squid 3.0 X-Git-Tag: SQUID_3_0_PRE6~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a78278e20e85cf529b542ca0e6bf332858129ece;p=thirdparty%2Fsquid.git Bug #1931: allow_underscore directive not available in Squid 3.0 This patch adds the allow_underscore squid.conf directive. Also changed the check_hostnames directive like in Squid 2.6, but off by default. --- diff --git a/configure.in b/configure.in index fde8a8e124..abdecd74aa 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ dnl Configuration input file for Squid dnl -dnl $Id: configure.in,v 1.447 2006/12/24 14:19:27 serassio Exp $ +dnl $Id: configure.in,v 1.448 2007/04/07 09:35:37 serassio Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AM_CONFIG_HEADER(include/autoconf.h) AC_CONFIG_AUX_DIR(cfgaux) AC_CONFIG_SRCDIR([src/main.cc]) AM_INIT_AUTOMAKE([tar-ustar]) -AC_REVISION($Revision: 1.447 $)dnl +AC_REVISION($Revision: 1.448 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -1336,34 +1336,6 @@ AC_ARG_ENABLE(truncate, fi ]) -dnl Disable hostname checks -AC_ARG_ENABLE(hostname-checks, -[ --enable-hostname-checks - Tells Squid to rejects any host names with - odd characters in their name to conform with - internet standards. This was the default in - prior Squid versions, but since Squid-3 Squid - no longer tries to police the use of DNS], -[ if test "$enableval" = "yes"; then - echo "Enabling hostname sanity checks" - 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 _ - in their name to conform with internet standards. - If you disagree with this you may allow _ in - hostnames by using this switch, provided that - the resolver library on the host where Squid runs - does not reject _ in hostnames...], -[ if test "$enableval" = "yes" ; then - echo "Enabling the use of underscores in host names" - AC_DEFINE(ALLOW_HOSTNAME_UNDERSCORES, 1,[Allow underscores in host names]) - fi -]) - dnl Select Default hosts file location AC_ARG_ENABLE(default-hostsfile, [ --enable-default-hostsfile=path diff --git a/src/cf.data.pre b/src/cf.data.pre index d4ba54fd66..ff5495f894 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.430 2007/04/06 04:50:05 rousskov Exp $ +# $Id: cf.data.pre,v 1.431 2007/04/07 09:35:38 serassio Exp $ # # # SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1509,12 +1509,23 @@ DOC_END NAME: check_hostnames TYPE: onoff -DEFAULT: on +DEFAULT: off LOC: Config.onoff.check_hostnames DOC_START - For security and stability reasons Squid by default checks - hostnames for Internet standard RFC compliance. If you do not want - Squid to perform these checks turn this directive off. + For security and stability reasons Squid can check + hostnames for Internet standard RFC compliance. If you want + Squid to perform these checks turn this directive on. +DOC_END + +NAME: allow_underscore +TYPE: onoff +DEFAULT: on +LOC: Config.onoff.allow_underscore +DOC_START + Underscore characers is not strictly allowed in Internet hostnames + but nevertheless used by many sites. Set this to off if you want + Squid to be strict about the standard. + This check is performed only when check_hostnames is set to on. DOC_END NAME: ftp_telnet_protocol diff --git a/src/structs.h b/src/structs.h index 16e579b902..9a42b0dafc 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.552 2007/04/06 04:50:06 rousskov Exp $ + * $Id: structs.h,v 1.553 2007/04/07 09:35:38 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -544,6 +544,7 @@ struct _SquidConfig int balance_on_multiple_ip; int relaxed_header_parser; int check_hostnames; + int allow_underscore; int via; int emailErrData; int httpd_suppress_version_string; diff --git a/src/url.cc b/src/url.cc index b50c867ba7..4b89bd6004 100644 --- a/src/url.cc +++ b/src/url.cc @@ -1,6 +1,6 @@ /* - * $Id: url.cc,v 1.155 2006/05/29 21:44:18 robertc Exp $ + * $Id: url.cc,v 1.156 2007/04/07 09:35:38 serassio Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -38,19 +38,16 @@ #include "URLScheme.h" static HttpRequest *urnParse(method_t method, char *urn); -#if CHECK_HOSTNAMES -static const char *const valid_hostname_chars = -#if ALLOW_HOSTNAME_UNDERSCORES +static const char valid_hostname_chars_u[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" - "0123456789-._"; -#else + "0123456789-._" + ; +static const char valid_hostname_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "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 */ @@ -286,13 +283,11 @@ urlParse(method_t method, char *url, HttpRequest *request) } } -#if CHECK_HOSTNAMES - if (Config.onoff.check_hostnames && strspn(host, valid_hostname_chars) != strlen(host)) { + if (Config.onoff.check_hostnames && strspn(host, Config.onoff.allow_underscore ? valid_hostname_chars_u : valid_hostname_chars) != strlen(host)) { debug(23, 1) ("urlParse: Illegal character in hostname '%s'\n", host); return NULL; } -#endif #if DONT_DO_THIS_IT_BREAKS_SEMANTIC_TRANSPARENCY /* remove trailing dots from hostnames */ while ((l = strlen(host)) > 0 && host[--l] == '.')