@@ -96,3 +96,38 @@ def test_inline_comments_filtered_but_standalone_kept():
9696 assert "Standalone" in texts
9797 # Inline comment should not appear as a standalone comment node
9898 assert not any (t and "Inline" in t for t in texts )
99+
100+
101+ def test_braced_variable_args_split ():
102+ """
103+ Regression test for braced variable tokenization.
104+
105+ Prior to ngxparse 0.5.16, crossplane incorrectly tokenized
106+ 'map ${var1}${var2} $result' as having a single arg '${var1}${var2} $result'
107+ instead of two separate args. This test ensures the fix works correctly.
108+ """
109+ config = """
110+ http {
111+ map ${detect_bot}${geo_list} $intermed {
112+ default 0;
113+ }
114+ }
115+ """
116+ nodes = RawParser ().parse (config )
117+
118+ # Find the map block
119+ def find_blocks (ns , name ):
120+ for x in ns :
121+ if x .get ("name" ) == name and x .get ("kind" ) == "block" :
122+ yield x
123+ if x .get ("kind" ) == "block" :
124+ yield from find_blocks (x .get ("children" , []), name )
125+
126+ map_blocks = list (find_blocks (nodes , "map" ))
127+ assert len (map_blocks ) == 1
128+ map_block = map_blocks [0 ]
129+
130+ # Args should be split correctly: ['${detect_bot}${geo_list}', '$intermed']
131+ assert len (map_block .get ("args" , [])) == 2
132+ assert map_block ["args" ][0 ] == "${detect_bot}${geo_list}"
133+ assert map_block ["args" ][1 ] == "$intermed"
0 commit comments