Skip to content

fix: parse adjacent set_by_lua_block opening brace - #178

Open
wow220809 wants to merge 1 commit into
nginxinc:mainfrom
wow220809:codex/set-by-lua-block-adjacent-brace
Open

fix: parse adjacent set_by_lua_block opening brace#178
wow220809 wants to merge 1 commit into
nginxinc:mainfrom
wow220809:codex/set-by-lua-block-adjacent-brace

Conversation

@wow220809

Copy link
Copy Markdown

Proposed changes

Fixes #177.

The Lua lexer previously collected the set_by_lua_block output variable
until it encountered whitespace. As a result, when the opening brace was
adjacent to the variable, such as $pass{, the lexer consumed the brace as
part of the argument and later failed while looking for the Lua block opener.

This change:

  • Treats an unquoted { as the end of the output-variable argument and the
    start of the Lua block.
  • Preserves ${variable} parameter expansion by not treating the first {
    after $ as the block opener.
  • Reuses the consumed opening brace as the initial Lua block depth.
  • Adds regression coverage for both spaced and adjacent opening braces with
    $pass and ${pass} forms.

This aligns the Lua lexer with the NGINX configuration tokenizer, where an
unquoted opening brace terminates the current argument and starts a block.

Validation

  • go test ./... -run '^TestLex_setByLuaBlockOpeningBraceDelimiter$' -count=1
  • go test -race ./... -count=1
  • go vet ./...
  • gofmt -d lua.go lex_test.go
  • golangci-lint v1.64.2 with new-issues-only checking

Checklist

  • I have read the CONTRIBUTING document
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • I have updated any relevant documentation (README.md) -- no documentation change is required for this lexer-only bug fix

Treat an unquoted opening brace as the end of the output-variable
argument.

Preserve ${variable} expansion handling and add regression coverage for
spaced and adjacent block openings.

Refs nginxinc#177.
@wow220809
wow220809 requested a review from a team as a code owner August 4, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lua lexer rejects valid set_by_lua_block when "{" immediately follows the output variable

1 participant