]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #1931: allow_underscore directive not available in Squid 3.0
authorserassio <>
Sat, 7 Apr 2007 15:35:37 +0000 (15:35 +0000)
committerserassio <>
Sat, 7 Apr 2007 15:35:37 +0000 (15:35 +0000)
This patch adds the allow_underscore squid.conf directive.
Also changed the check_hostnames directive like in Squid 2.6, but off
by default.

configure.in
src/cf.data.pre
src/structs.h
src/url.cc

index fde8a8e124c11425e9102e743ae5ba7d82762640..abdecd74aafe0a9181288c9211eb923d9df6fbfa 100644 (file)
@@ -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
index d4ba54fd66a95a095269eec4bbcebf2ea4dbfc68..ff5495f8940cce85d9a6685f1a543dd3c398090b 100644 (file)
@@ -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
index 16e579b902a5a7ad9c497cdf77dc28289cc6ce69..9a42b0dafc3555186e5fc3b1f8af32afdcc36c8f 100644 (file)
@@ -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;
index b50c867ba726d4f373e6cc504360c88de4119add..4b89bd600462624ac107d748f9727a5973126adb 100644 (file)
@@ -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
 #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] == '.')