Skip to content

Commit

Permalink
Fix unquoting values when followed by space
Browse files Browse the repository at this point in the history
  • Loading branch information
etingof committed Aug 18, 2018
1 parent 6dcc472 commit 0076190
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@


Revision 0.2.6, released XX-08-2018
-----------------------------------

- Fixed unquoting values when followed by space

Revision 0.2.5, released 15-08-2018
-----------------------------------

Expand Down
2 changes: 1 addition & 1 deletion apacheconfig/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# http://www.python.org/dev/peps/pep-0396/
__version__ = '0.2.5'
__version__ = '0.2.6'

from contextlib import contextmanager

Expand Down
1 change: 0 additions & 1 deletion apacheconfig/apacheconfigtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def main():
sys.stderr.write('Malformed defaultconfig %s: %s\n' % (options['defaultconfig'], ex))
return 1


if args.json_input:

with make_loader(**options) as loader:
Expand Down
9 changes: 5 additions & 4 deletions apacheconfig/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ def _parse_option_value(token):
if not option:
raise ApacheConfigError('Syntax error in option-value pair %s' % token)
if value:
if value[0] == '"' and value[-1] == '"':
value = DoubleQuotedString(value[1:-1])
if value[0] == "'" and value[-1] == "'":
value = SingleQuotedString(value[1:-1])
stripped = value.strip()
if stripped[0] == '"' and stripped[-1] == '"':
value = DoubleQuotedString(stripped[1:-1])
if stripped[0] == "'" and stripped[-1] == "'":
value = SingleQuotedString(stripped[1:-1])
if '#' in value:
value = value.replace('\\#', '#')
return option, value
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def testOptionAndValueSet(self):
a =b
a b
a "b"
a = "b"
a = "b"
a = 'b'
"""
ApacheConfigLexer = make_lexer()
ApacheConfigParser = make_parser()
Expand All @@ -140,6 +141,7 @@ def testOptionAndValueSet(self):
['statement', 'a', 'b'],
['statement', 'a', 'b'],
['statement', 'a', 'b'],
['statement', 'a', 'b'],
['statement', 'a', 'b']])

def testBlockWithOptions(self):
Expand Down

0 comments on commit 0076190

Please sign in to comment.