Skip to content

Commit

Permalink
Merge pull request #54 from nginxinc/fix-directives-with-space
Browse files Browse the repository at this point in the history
Fixed directives with spaces not being quoted
  • Loading branch information
aluttik authored Dec 5, 2018
2 parents 885eddc + 61cd5cc commit 3cc8f98
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 1 addition & 4 deletions crossplane/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ def _build_lines(objs):
state['depth'] = state['depth'] + 1

for obj in objs:
directive = obj['directive']

if directive == '':
directive = _enquote(directive)
directive = _enquote(obj['directive'])

if directive in EXTERNAL_BUILDERS:
external_builder = EXTERNAL_BUILDERS[directive]
Expand Down
8 changes: 8 additions & 0 deletions tests/configs/directive-with-space/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
events {
}
http {
map $http_user_agent $mobile {
default 0;
'~Opera Mini' 1;
}
}
4 changes: 4 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,7 @@ def test_compare_parsed_and_built_russian_text(tmpdir):

def test_compare_parsed_and_built_quoted_right_brace(tmpdir):
compare_parsed_and_built('quoted-right-brace', 'nginx.conf', tmpdir)


def test_compare_parsed_and_built_directive_with_space(tmpdir):
compare_parsed_and_built('directive-with-space', 'nginx.conf', tmpdir)

0 comments on commit 3cc8f98

Please sign in to comment.