]> git.ipfire.org Git - thirdparty/squid.git/commit - src/cf.data.pre
Fix configuration file parsing bugs, related to quoted strings
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Thu, 29 Aug 2013 09:21:53 +0000 (12:21 +0300)
committerChristos Tsantilas <chtsanti@users.sourceforge.net>
Thu, 29 Aug 2013 09:21:53 +0000 (12:21 +0300)
commitbde7a8ce7345bde24125a182fd3d2a4f18ea3789
treef45cdf9b927d3f1b76e994720661c35627e6adb7
parent71c670251b9db2afbd8be0181366a51fec44f3b9
Fix configuration file parsing bugs, related to quoted strings

This is patch try to fix problems discussed under the "[PATCH] Unknown cfg function"
mail thread on squid-dev mailing list

Fixes/changes:
 - The quoted tokens mode (configuration_includes_quoted_values parameter)
   is  set to off by default

 - If configuration_includes_quoted_values is off the quoted tokens
   parsed using the ConfigParser::NextToken include the quotes, to keep
   compatibility with older releases.

 - The methods ConfigParser::RegexPattern() and ConfigParser::RegexStrtokFile()
   added to parse regex tokens. The regex tokens can not be quoted values but
   have their own syntax.

 - For the cases where quoted strings are required (wordlists, Notes
   parsing, Headers with acl), the new ConfigParser::NextQuotedToken method
   added.
   The old wordlists parser allowed escaping any character, this patch
   will return an error if you try to escape alphanumeric characters. The
   \r \n and \t have the C semantics.

 - Removes the ConfigParser::TokenUndo method. The new method
   ConfigParser::NextTokenPreview() which can be used to preview the next
   token is added. This method if the next token is invalid (eg unquoted
   with special characters) instead of calling self_destruct it will return
   the "[invalid token]" as token.

 - A set of new flags defined under ConfigParser class to define the type of
   parsing: ParseRegex_ (next token is regex)  ParseQuotedOrToEOL_
   (next token is quoted or to-EOL), PreviewMode_ (just do preview do not
   pop next token)

 - Currently parser read a line, and the tokens stored on this line
   and the line modified while parsed.
   This patch extracts the tokens from line and store them to
   ConfigParser::CfgLineTokens_ member. This method selected because
     1) We may need to parse again the line so we do not want to modify it.
        For example call the ConfigParser::PeekAtToken method to check if it
        is a flag token ( eg "-i"), and if not call the
        ConfigParser::RegexPattern() method to read next regex expression.
     2) The current line tokens must stored somewhere to support the following:
        char *name = ConfigParser::NextToken();
        char *value = ConfigParser::NextToken();
   The ConfigParser::CfgLineTokens_ reset when a new config line is read.

TODO:
 - The ConfigParser::TokenPutBack method probably should removed in the future
   together with the ConfigParser::Undo_ and ConfigParser::Undo().
   This method is currently used only in one place (acl regex).
src/ConfigParser.cc
src/ConfigParser.h
src/Notes.cc
src/acl/Acl.cc
src/acl/RegexData.cc
src/cache_cf.cc
src/cf.data.depend
src/cf.data.pre