webantic / nginx-config-parser

Parse nginx config strings into js objects and back
Other
51 stars 19 forks source link

Semicolon and/or curly brackets inside single/double quotes in single/multi-line directives. #22

Open amorozkin opened 2 years ago

amorozkin commented 2 years ago

From Nginx perspective any of next two constructions is valid:

A.

add_header Strict-Transport-Security "max-age=0; includeSubDomains" always;

B.

add_header Strict-Transport-Security " max-age=0 ; includeSubDomains " always ;

But both ones can't be parsed correctly.

amorozkin commented 2 years ago

See no options for now other than to roll back these PRs:

https://github.com/webantic/nginx-config-parser/pull/18 https://github.com/webantic/nginx-config-parser/pull/20

And use https://github.com/nginxinc/crossplane tool to get "normalised" input config:

crossplane parse --indent=4 --combine /etc/nginx/nginx.conf > nginx_crossplane_parse.json PYTHONIOENCODING=UTF-8 crossplane build --stdout nginx_crossplane_parse.json > nginx_crossplane_build.conf

It would eliminate both multi-line blocks and multiblok lines.

The Nginx crossplane tool has portings to Go and Ruby - not to JS so for.