Skip to content

Commit 7e2f8ce

Browse files
committed
Fix: ConfigParser incorrectly parses tokens with @ character
1 parent 3b19365 commit 7e2f8ce

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

stormshield/sns/configparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __init__(self, text):
9494
line = line.encode('utf-8')
9595
# parse token=value token2=value2
9696
lexer = shlex(line, posix=True)
97-
lexer.wordchars += "=.-*:,/"
97+
lexer.wordchars += "=.-*:,/@"
9898
parsed = {}
9999
for word in lexer:
100100
# ignore anything else than token=value

stormshield/sns/sslclient/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# major: breaking API change
33
# minor: new functionality
44
# patch: bugfix
5-
__version__ = "1.0.2"
5+
__version__ = "1.0.3"

tests/test_configparser.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def test_empty_value(self):
173173
self.assertEqual(expected, config.data)
174174

175175
def test_slash_in_value(self):
176-
""" test parsing of value with slash character """
176+
""" Test parsing of value with slash character """
177177

178178
input = """101 code=00a01000 msg="Begin" format="section_line"
179179
[StaticRoutes]
@@ -187,6 +187,21 @@ def test_slash_in_value(self):
187187
config = ConfigParser(input)
188188
self.assertEqual(expected, config.data)
189189

190+
def test_arobase_in_value(self):
191+
""" Test parsing of value with @ character """
192+
193+
input = """101 code=00a01000 msg="Begin" format="section_line"
194+
[Result]
195+
ruleid=1 state=on action=pass from=*@* to=*@* comment="default rule (pass all)"
196+
100 code=00a00100 msg="Ok"\""""
197+
198+
expected = {'Result': [
199+
{'ruleid': '1', 'state': 'on', 'action': 'pass', 'from': '*@*',
200+
'to': '*@*', 'comment': 'default rule (pass all)'}]}
201+
202+
config = ConfigParser(input)
203+
self.assertEqual(expected, config.data)
204+
190205

191206
if __name__ == '__main__':
192207
unittest.main()

0 commit comments

Comments
 (0)