From e81d3f9bd7a2fdb52588202cc5c9b21c8eecbb82 Mon Sep 17 00:00:00 2001 From: Ruben Tsirunyan Date: Wed, 6 Jun 2018 17:53:04 +0400 Subject: [PATCH 1/4] Adding some common characters to the components --- parse_apache_configs/parse_config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parse_apache_configs/parse_config.py b/parse_apache_configs/parse_config.py index 99452b7..2d11b66 100644 --- a/parse_apache_configs/parse_config.py +++ b/parse_apache_configs/parse_config.py @@ -5,16 +5,16 @@ # a conditional expression. The reason this is done # is so that a tag with the ">" operator in the # arguments will parse correctly. -OPERAND = Word(alphanums + "." + '"' + '/-' + "*:^_![]?$%@)(#=`" + '\\') +OPERAND = Word(alphanums + "." + '"' + '/-' + "*:^_|![]?$%@)(#=`'}{" + '\\') OPERATOR = oneOf(["<=", ">=", "==", "!=", "<", ">", "~"], useRegex=False) -EXPRESSION_TAG = OPERAND + White() + OPERATOR + White() + OPERAND +EXPRESSION_TAG = Word(alphanums) + White() + OPERAND + White() + OPERATOR + White() + OPERAND # LITERAL_TAG will match tags that do not have # a conditional expression. So any other tag # with arguments that don't contain OPERATORs LITERAL_TAG = OneOrMore(Word( alphanums + '*:' + '/' + '"-' + '.' + " " + "^" + "_" + "!" + "[]?$" - + "'" + '\\' + + "'" + '\\' + "*:^_|![]?$%@)(#=`'}{" )) # Will match the start of any tag TAG_START_GRAMMAR = Group(Literal("<") + (EXPRESSION_TAG | LITERAL_TAG) From 155f152f936d0fef5544f8df763f2cffad2f0769 Mon Sep 17 00:00:00 2001 From: Ruben Tsirunyan Date: Thu, 7 Jun 2018 14:23:36 +0400 Subject: [PATCH 2/4] Adding some new characters to be parsed --- parse_apache_configs/parse_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parse_apache_configs/parse_config.py b/parse_apache_configs/parse_config.py index 2d11b66..3d922ce 100644 --- a/parse_apache_configs/parse_config.py +++ b/parse_apache_configs/parse_config.py @@ -5,7 +5,7 @@ # a conditional expression. The reason this is done # is so that a tag with the ">" operator in the # arguments will parse correctly. -OPERAND = Word(alphanums + "." + '"' + '/-' + "*:^_|![]?$%@)(#=`'}{" + '\\') +OPERAND = Word(alphanums + "." + '"' + '/-' + "*:^_|![]?$%@)(#=`'}{&+~" + '\\') OPERATOR = oneOf(["<=", ">=", "==", "!=", "<", ">", "~"], useRegex=False) EXPRESSION_TAG = Word(alphanums) + White() + OPERAND + White() + OPERATOR + White() + OPERAND @@ -14,7 +14,7 @@ # with arguments that don't contain OPERATORs LITERAL_TAG = OneOrMore(Word( alphanums + '*:' + '/' + '"-' + '.' + " " + "^" + "_" + "!" + "[]?$" - + "'" + '\\' + "*:^_|![]?$%@)(#=`'}{" + + "'" + '\\' + "*:^_|![]?$%@)(#=`'}{&+~" )) # Will match the start of any tag TAG_START_GRAMMAR = Group(Literal("<") + (EXPRESSION_TAG | LITERAL_TAG) From 9f0e3fa0326d9b90a004e31cda68d0a386eef2db Mon Sep 17 00:00:00 2001 From: Rick Hornsby Date: Sat, 16 Jun 2018 19:20:09 -0500 Subject: [PATCH 3/4] Allow for directives like "php_value" --- parse_apache_configs/parse_config.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/parse_apache_configs/parse_config.py b/parse_apache_configs/parse_config.py index 3d922ce..6dd7f50 100644 --- a/parse_apache_configs/parse_config.py +++ b/parse_apache_configs/parse_config.py @@ -27,10 +27,9 @@ # Will match any directive. We are performing # a simple parse by matching the directive on # the left, and everything else on the right. -ANY_DIRECTIVE = Group(Word(alphanums) + Suppress(White()) +ANY_DIRECTIVE = Group(Word(alphanums, alphanums+'_-@.') + Suppress(White()) + Word(printables + " ") + LineEnd()) - COMMENT = Group( (Literal("#") + LineEnd()) ^ (Literal("#") From 8d61321bfc846b11cb07b542ca3ea035f988527a Mon Sep 17 00:00:00 2001 From: Rick Hornsby Date: Sun, 17 Jun 2018 16:02:38 -0500 Subject: [PATCH 4/4] Simplify call to `Word` constructor. --- parse_apache_configs/parse_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parse_apache_configs/parse_config.py b/parse_apache_configs/parse_config.py index 6dd7f50..b6adfd9 100644 --- a/parse_apache_configs/parse_config.py +++ b/parse_apache_configs/parse_config.py @@ -27,7 +27,7 @@ # Will match any directive. We are performing # a simple parse by matching the directive on # the left, and everything else on the right. -ANY_DIRECTIVE = Group(Word(alphanums, alphanums+'_-@.') + Suppress(White()) +ANY_DIRECTIVE = Group(Word(alphanums+'_-@.') + Suppress(White()) + Word(printables + " ") + LineEnd()) COMMENT = Group(