Added support for conditionally using case sensitive filtering files.

Code changes from James E. Flemer.
This commit is contained in:
Robert James Kaes 2003-01-27 17:57:45 +00:00
parent 1624979f13
commit cb7e3eef04
5 changed files with 23 additions and 5 deletions

View File

@ -132,6 +132,11 @@ Allow 192.168.1.0/25
# #
#FilterExtended On #FilterExtended On
#
# Use case sensitive regular expressions.
#
#FilterCaseSensitive On
# #
# Change the default policy of the filtering system. If this directive is # Change the default policy of the filtering system. If this directive is
# commented out, or is set to "No" then the default policy is to allow everything # commented out, or is set to "No" then the default policy is to allow everything

View File

@ -1,4 +1,4 @@
/* $Id: filter.c,v 1.15 2002-10-03 20:40:39 rjkaes Exp $ /* $Id: filter.c,v 1.16 2003-01-27 17:57:39 rjkaes Exp $
* *
* Copyright (c) 1999 George Talusan (gstalusan@uwaterloo.ca) * Copyright (c) 1999 George Talusan (gstalusan@uwaterloo.ca)
* Copyright (c) 2002 James E. Flemer (jflemer@acm.jhu.edu) * Copyright (c) 2002 James E. Flemer (jflemer@acm.jhu.edu)
@ -57,9 +57,11 @@ filter_init(void)
if (fd) { if (fd) {
p = NULL; p = NULL;
cflags = REG_NEWLINE | REG_NOSUB | REG_ICASE; cflags = REG_NEWLINE | REG_NOSUB;
if (config.filter_extended) if (config.filter_extended)
cflags |= REG_EXTENDED; cflags |= REG_EXTENDED;
if (!config.filter_casesensitive)
cflags |= REG_ICASE;
while (fgets(buf, FILTER_BUFFER_LEN, fd)) { while (fgets(buf, FILTER_BUFFER_LEN, fd)) {
s = buf; s = buf;

View File

@ -1,4 +1,4 @@
/* $Id: grammar.y,v 1.17 2002-11-26 21:44:43 rjkaes Exp $ /* $Id: grammar.y,v 1.18 2003-01-27 17:57:39 rjkaes Exp $
* *
* This is the grammar for tinyproxy's configuration file. It needs to be * This is the grammar for tinyproxy's configuration file. It needs to be
* in sync with scanner.l. If you know more about yacc and lex than I do * in sync with scanner.l. If you know more about yacc and lex than I do
@ -48,6 +48,7 @@ int yylex(void);
%token KW_USER KW_GROUP %token KW_USER KW_GROUP
%token KW_ANONYMOUS KW_XTINYPROXY %token KW_ANONYMOUS KW_XTINYPROXY
%token KW_FILTER KW_FILTERURLS KW_FILTEREXTENDED KW_FILTER_DEFAULT_DENY %token KW_FILTER KW_FILTERURLS KW_FILTEREXTENDED KW_FILTER_DEFAULT_DENY
%token KW_FILTER_CASESENSITIVE
%token KW_UPSTREAM %token KW_UPSTREAM
%token KW_CONNECTPORT KW_BIND KW_HTTP_VIA %token KW_CONNECTPORT KW_BIND KW_HTTP_VIA
%token KW_ALLOW KW_DENY %token KW_ALLOW KW_DENY
@ -133,6 +134,14 @@ statement
config.filter_extended = $2; config.filter_extended = $2;
#else #else
log_message(LOG_WARNING, "Filter support was not compiled in."); log_message(LOG_WARNING, "Filter support was not compiled in.");
#endif
}
| KW_FILTER_CASESENSITIVE yesno
{
#ifdef FILTER_ENABLE
config.filter_casesensitive = $2;
#else
log_message(LOG_WARNING, "Filter support was not compiled in.");
#endif #endif
} }
| KW_FILTER_DEFAULT_DENY yesno | KW_FILTER_DEFAULT_DENY yesno

View File

@ -1,4 +1,4 @@
/* $Id: scanner.l,v 1.16 2002-11-26 21:44:43 rjkaes Exp $ /* $Id: scanner.l,v 1.17 2003-01-27 17:57:38 rjkaes Exp $
* *
* This builds the scanner for the tinyproxy configuration file. This * This builds the scanner for the tinyproxy configuration file. This
* file needs to stay in sync with grammar.y. If someone knows lex and yacc * file needs to stay in sync with grammar.y. If someone knows lex and yacc
@ -47,6 +47,7 @@ static struct keyword keywords[] = {
{ "filterurls", KW_FILTERURLS }, { "filterurls", KW_FILTERURLS },
{ "filterextended", KW_FILTEREXTENDED }, { "filterextended", KW_FILTEREXTENDED },
{ "filterdefaultdeny", KW_FILTER_DEFAULT_DENY }, { "filterdefaultdeny", KW_FILTER_DEFAULT_DENY },
{ "filtercasesensitive", KW_FILTER_CASESENSITIVE },
{ "xtinyproxy", KW_XTINYPROXY }, { "xtinyproxy", KW_XTINYPROXY },
{ "upstream", KW_UPSTREAM }, { "upstream", KW_UPSTREAM },
{ "allow", KW_ALLOW }, { "allow", KW_ALLOW },

View File

@ -1,4 +1,4 @@
/* $Id: tinyproxy.h,v 1.36 2002-12-04 17:06:14 rjkaes Exp $ /* $Id: tinyproxy.h,v 1.37 2003-01-27 17:57:37 rjkaes Exp $
* *
* See 'tinyproxy.c' for a detailed description. * See 'tinyproxy.c' for a detailed description.
* *
@ -38,6 +38,7 @@ struct config_s {
char *filter; char *filter;
unsigned int filter_url; /* boolean */ unsigned int filter_url; /* boolean */
unsigned int filter_extended; /* boolean */ unsigned int filter_extended; /* boolean */
unsigned int filter_casesensitive; /* boolean */
#endif /* FILTER_ENABLE */ #endif /* FILTER_ENABLE */
#ifdef XTINYPROXY_ENABLE #ifdef XTINYPROXY_ENABLE
char *my_domain; char *my_domain;