Skip to content

Support string API#117

Open
dvershinin wants to merge 25 commits intonginxinc:masterfrom
dvershinin:master
Open

Support string API#117
dvershinin wants to merge 25 commits intonginxinc:masterfrom
dvershinin:master

Conversation

@dvershinin
Copy link

Proposed changes

Currently you have to create a temporary file just so you can call crossplane.parse on it, which seems needlessly awkward.

Gixy analyzer tool would particularly benefit from this, as it reads config files first (from stdin often), then has to create temp files because crossplane does not yet support a string API.

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto master
  • I will ensure my PR is targeting the master branch and pulling from my branch from my own fork

Fix EOF lexing for unterminated directives
Shorter name that doesn't imply nginx is bundled.
Import name and CLI remain `crossplane` for backward compatibility.
- Fix fname variable scope leak in parser.py where the loop variable
  in include handling shadowed the outer fname, causing directives
  after includes to have incorrect file attributes when combine=True

- Add support for map, types, geo, and charset_map blocks in strict
  mode by recognizing them as freeform contexts where arbitrary
  directive names are allowed (MIME types, mapping keys, etc.)

- Add comprehensive tests for both fixes
When parsing nginx config like 'map ${var1}${var2} $result',
the lexer was incorrectly returning a single token '${var1}${var2} $result'
instead of two tokens '${var1}${var2}' and '$result'.

The issue was in the braced variable handler: after consuming the closing },
it didn't check if the next character was whitespace that should end the token.
The fix adds a check after the brace loop to yield the token and continue
if whitespace follows.

Bump version to 0.5.16.
Bug fixes:
- Fix Lua block string escape handling to properly preserve backslash
  escapes like \" inside quoted strings
- Use context manager for file access check in parser.py

Typo corrections:
- lua.py: "unxpected" -> "unexpected"
- parser.py: "representaions" -> "representations"
- parser.py: "contianing" -> "containing"
- parser.py: "parsin'" -> "parsing"

New tests:
- test_cli.py: Tests for CLI argument parsing and all subcommands
- test_errors.py: Tests for exception classes and hierarchy
- test_abstract.py: Tests for extension base class
- Expanded test_analyze.py with directive validation tests

Test fixtures:
- Added cli-test config directory for CLI testing
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.

1 participant