Skip to content

Commit 7d2f3c2

Browse files
author
Joshua Rogers
committed
restrict hash blocks to only: map, types, geo, and charset
1 parent 30bf346 commit 7d2f3c2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gixy/parser/raw_parser.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
from pyparsing import (
1010
Literal, Suppress, White, Word, alphanums, Forward, Group, Optional, Combine,
11-
Keyword, OneOrMore, ZeroOrMore, Regex, QuotedString, nestedExpr, ParseResults)
11+
Keyword, OneOrMore, ZeroOrMore, Regex, QuotedString, nestedExpr, ParseResults,
12+
oneOf)
1213

1314
LOG = logging.getLogger(__name__)
1415

@@ -56,6 +57,7 @@ def script(self):
5657
keyword = Word(alphanums + ".+-_/")
5758
path = Word(alphanums + ".-_/")
5859
variable = Word("$_-" + alphanums)
60+
known_hash_blocks = oneOf("map types geo charset")
5961
value_wq = Regex(r'(?:\([^\s;]*\)|\$\{\w+\}|[^\s;(){}])+')
6062
value_sq = NginxQuotedString(quoteChar="'")
6163
value_dq = NginxQuotedString(quoteChar='"')
@@ -149,7 +151,7 @@ def script(self):
149151
)("block")
150152

151153
hash_block << (
152-
keyword +
154+
known_hash_blocks +
153155
Group(OneOrMore(space + value)) +
154156
Group(
155157
left_bracket +

0 commit comments

Comments
 (0)