fix: parse adjacent set_by_lua_block opening brace - #178
Open
wow220809 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Fixes #177.
The Lua lexer previously collected the
set_by_lua_blockoutput variableuntil it encountered whitespace. As a result, when the opening brace was
adjacent to the variable, such as
$pass{, the lexer consumed the brace aspart of the argument and later failed while looking for the Lua block opener.
This change:
{as the end of the output-variable argument and thestart of the Lua block.
${variable}parameter expansion by not treating the first{after
$as the block opener.$passand${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=1go test -race ./... -count=1go vet ./...gofmt -d lua.go lex_test.gogolangci-lint v1.64.2with new-issues-only checkingChecklist
CONTRIBUTINGdocumentREADME.md) -- no documentation change is required for this lexer-only bug fix