File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -516,7 +516,7 @@ def loads(data, conf=True):
516516 index += m .end ()
517517 continue
518518
519- if ";" not in data [index :] and index + 1 != len ( data ) :
519+ if ";" not in data [index :] and "}" in data [ index :] :
520520 # If there is still something to parse, expect ';' otherwise
521521 # the Key regexp can get stuck due to regexp catastrophic backtracking
522522 raise ParseError ("Config syntax, missing ';' at index: {}" .format (index ))
Original file line number Diff line number Diff line change 213213}
214214"""
215215
216+ TESTBLOCK_CASE_13 = """
217+ server{
218+ }"""
219+
216220
217221class TestPythonNginx (unittest .TestCase ):
218222 def test_basic_load (self ):
@@ -332,12 +336,15 @@ def test_missing_semi_colon(self):
332336 with pytest .raises (nginx .ParseError ) as e :
333337 nginx .loads (TESTBLOCK_CASE_11 )
334338 self .assertEqual (str (e .value ), "Config syntax, missing ';' at index: 189" )
335-
339+
336340 def test_brace_inside_block_param (self ):
337341 inp_data = nginx .loads (TESTBLOCK_CASE_12 )
338342 self .assertEqual (len (inp_data .server .filter ("Location" )), 1 )
339343 self .assertEqual (inp_data .server .filter ("Location" )[0 ].value , "~ \" ^/(test|[0-9a-zA-Z]{6})$\" " )
340344
345+ def test_server_without_last_linebreak (self ):
346+ self .assertTrue (nginx .loads (TESTBLOCK_CASE_13 ) is not None )
347+
341348
342349if __name__ == '__main__' :
343350 unittest .main ()
You can’t perform that action at this time.
0 commit comments